Skip to content

Commit

Permalink
fix: debug reading from .env, minor .env refactors
Browse files Browse the repository at this point in the history
  • Loading branch information
Golf0ned committed Nov 27, 2023
1 parent 25f0558 commit cf3af41
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
16 changes: 8 additions & 8 deletions bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
import tournament

load_dotenv()
TOKEN = 'DISCORD_TOKEN'
GUILD_ID = 'GUILD_ID'
DEBUG = 'DEBUG'
TOKEN = os.getenv('DISCORD_TOKEN')
GUILD_ID = os.getenv('GUILD_ID')
DEBUG = int(os.getenv('DEBUG'))

Pairings = pairings.PairingsManager()

Expand All @@ -24,13 +24,13 @@
activity=discord.Activity(type=discord.ActivityType.watching,
name="pairings | /help"))
tree = app_commands.CommandTree(client)
activeGuild = discord.Object(id=os.getenv(GUILD_ID))
activeGuild = discord.Object(id=GUILD_ID)



@client.event
async def on_ready():
if os.getenv(DEBUG):
if DEBUG:
print('[DEBUG] Debug is on.')
print(f'Logged in as {client.user} (ID: {client.user.id})')
print("Loading commands...")
Expand All @@ -44,7 +44,7 @@ async def on_ready():

@tree.command(name="help",
description="Displays all commands for PairingsBot.",
guild=discord.Object(id=os.getenv(GUILD_ID)))
guild=activeGuild)
async def pairingsHelp(interaction):
commands = [("/help", "Displays all commands for PairingsBot."),
("/configureblasts <school> <channel>", "Sets the school to filter pairings by and the channel that blasts should be sent to."),
Expand Down Expand Up @@ -227,7 +227,7 @@ def randomPairingsMessage():



if os.getenv(DEBUG):
if DEBUG:
@tree.command(name="quickconfig", description="Quick config for testing.", guild=activeGuild)
async def quickConfig(interaction):
school = 'SCHOOL_NAME'
Expand All @@ -247,4 +247,4 @@ async def testBlast(interaction):



client.run(os.getenv(TOKEN))
client.run(TOKEN)
4 changes: 2 additions & 2 deletions pairings.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import tournament

load_dotenv()
DEBUG = 'DEBUG'
DEBUG = int(os.getenv('DEBUG'))

class PairingsManager():

Expand Down Expand Up @@ -58,6 +58,6 @@ def getRoundInfo(self):

return res

if os.getenv(DEBUG):
if DEBUG:
def testBlast(self):
self.__hasBlast = True

0 comments on commit cf3af41

Please sign in to comment.