Skip to content

Commit

Permalink
fix: do not hard code token
Browse files Browse the repository at this point in the history
  • Loading branch information
sushichan044 committed Sep 18, 2023
1 parent 80bb6df commit cd5aa99
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
8 changes: 4 additions & 4 deletions app/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,17 +103,17 @@ async def write_debug_log(ctx: commands.Context) -> None:
# traces_sample_rate=1.0,
# )

def runner(self) -> None:
def runner(self, *, token: str) -> None:
try:
asyncio.run(self._runner())
asyncio.run(self._runner(token=token))
except ValueError:
self.logger.exception("Failed to start bot")
asyncio.run(self.shutdown(status=1))

async def _runner(self) -> None:
async def _runner(self, *, token: str) -> None:
try:
async with self:
await self.start(os.environ["DISCORD_BOT_TOKEN"])
await self.start(token)
except TypeError:
self.logger.exception("Failed to start bot")
await self.shutdown()
Expand Down
4 changes: 3 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import os

from app.bot import Bot

if __name__ == "__main__":
bot = Bot()
bot.runner()
bot.runner(token=os.environ["DISCORD_BOT_TOKEN"])

0 comments on commit cd5aa99

Please sign in to comment.