Formatted files with black

This commit is contained in:
2023-01-13 23:35:42 +01:00
parent 37ec0cf0c7
commit e2b2fb5abb
252 changed files with 6085 additions and 3791 deletions

View File

@@ -19,23 +19,24 @@ from modules.database.database_extension import DatabaseExtension
class Program:
def __init__(self):
self.app: Optional[Application] = None
async def start(self):
# discord extension has to be loaded before modules (modules depends on discord stuff)
app_builder = ApplicationBuilder(Application) \
.use_extension(StartupSettingsExtension) \
.use_extension(StartupDiscordExtension) \
.use_extension(StartupModuleExtension) \
.use_extension(StartupMigrationExtension) \
.use_extension(InitBotExtension) \
.use_extension(BootLogExtension) \
.use_extension(DatabaseExtension) \
.use_extension(AppApiExtension) \
.use_extension(CoreExtension) \
app_builder = (
ApplicationBuilder(Application)
.use_extension(StartupSettingsExtension)
.use_extension(StartupDiscordExtension)
.use_extension(StartupModuleExtension)
.use_extension(StartupMigrationExtension)
.use_extension(InitBotExtension)
.use_extension(BootLogExtension)
.use_extension(DatabaseExtension)
.use_extension(AppApiExtension)
.use_extension(CoreExtension)
.use_startup(Startup)
)
self.app: Application = await app_builder.build_async()
await self.app.run_async()
@@ -52,19 +53,25 @@ def main():
except KeyboardInterrupt:
asyncio.run(program.stop())
except Exception as e:
Console.error(f'[ ERROR ] [ {__name__} ]: Cannot start the bot', f'{e} -> {traceback.format_exc()}')
Console.error(
f"[ ERROR ] [ {__name__} ]: Cannot start the bot",
f"{e} -> {traceback.format_exc()}",
)
finally:
try:
asyncio.run(program.stop())
except Exception as e:
Console.error(f'[ ERROR ] [ {__name__} ]: Cannot stop the bot', f'{e} -> {traceback.format_exc()}')
Console.error(
f"[ ERROR ] [ {__name__} ]: Cannot stop the bot",
f"{e} -> {traceback.format_exc()}",
)
if program.app is not None and program.app.is_restart():
del program
main()
if __name__ == '__main__':
if __name__ == "__main__":
main()
# ((