init and build db earlier
This commit is contained in:
parent
77cb214276
commit
6e780f5b04
15
bot.py
15
bot.py
@ -48,14 +48,6 @@ class DiscordBot(commands.Bot):
|
||||
# Sync app commands
|
||||
await self.wait_until_ready()
|
||||
await self.tree.sync()
|
||||
|
||||
# Open database connection
|
||||
await Tortoise.init(
|
||||
db_url= f"sqlite://{str(DATA_DIR)}/db.sqlite",
|
||||
modules={"models": ["utils.models"]}
|
||||
)
|
||||
await Tortoise.generate_schemas()
|
||||
|
||||
log.info("Discord Bot is ready")
|
||||
|
||||
async def close(self):
|
||||
@ -124,6 +116,13 @@ async def main():
|
||||
setup_logging_config(debug_mode)
|
||||
bot_token = get_bot_token()
|
||||
|
||||
# Open database connection
|
||||
await Tortoise.init(
|
||||
db_url= f"sqlite://{str(DATA_DIR)}/db.sqlite",
|
||||
modules={"models": ["utils.models"]}
|
||||
)
|
||||
await Tortoise.generate_schemas()
|
||||
|
||||
async with DiscordBot(debug_mode) as bot:
|
||||
await bot.load_cogs()
|
||||
await bot.start(bot_token, reconnect=True)
|
||||
|
Reference in New Issue
Block a user