From ac1affa937e85c5d992034de28a1b03a4395a3ea Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Tue, 21 Feb 2023 13:19:34 +0100 Subject: [PATCH] Fixed seeder and module order #214 --- kdb-bot/src/bot/module_list.py | 2 +- kdb-bot/src/modules/database/database_on_ready_event.py | 4 ++-- kdb-bot/src/modules/level/level_seeder.py | 4 ++++ 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/kdb-bot/src/bot/module_list.py b/kdb-bot/src/bot/module_list.py index 700f0c73..120926ef 100644 --- a/kdb-bot/src/bot/module_list.py +++ b/kdb-bot/src/bot/module_list.py @@ -25,10 +25,10 @@ class ModuleList: DataModule, GraphQLModule, PermissionModule, + LevelModule, DatabaseModule, AutoRoleModule, BaseModule, - LevelModule, ApiModule, TechnicianModule, # has to be last! diff --git a/kdb-bot/src/modules/database/database_on_ready_event.py b/kdb-bot/src/modules/database/database_on_ready_event.py index bf592bf4..3b66f5e0 100644 --- a/kdb-bot/src/modules/database/database_on_ready_event.py +++ b/kdb-bot/src/modules/database/database_on_ready_event.py @@ -375,8 +375,6 @@ class DatabaseOnReadyEvent(OnReadyABC): async def on_ready(self): self._logger.debug(__name__, f"Module {type(self)} started") - await self._seeder.seed() - self._check_known_users() self._check_servers() self._check_clients() @@ -385,5 +383,7 @@ class DatabaseOnReadyEvent(OnReadyABC): self._check_user_joins_vc() self._check_user_joined_gs() + await self._seeder.seed() + self._validate_init_time() self._logger.trace(__name__, f"Module {type(self)} stopped") diff --git a/kdb-bot/src/modules/level/level_seeder.py b/kdb-bot/src/modules/level/level_seeder.py index 36487873..1ed5ab7d 100644 --- a/kdb-bot/src/modules/level/level_seeder.py +++ b/kdb-bot/src/modules/level/level_seeder.py @@ -1,4 +1,5 @@ import discord +from cpl_core.database.context import DatabaseContextABC from cpl_discord.container import Guild from cpl_discord.service import DiscordBotServiceABC from discord import Permissions, Colour @@ -21,6 +22,7 @@ class LevelSeeder(DataSeederABC): level_repo: LevelRepositoryService, servers: ServerRepositoryABC, level: LevelService, + db: DatabaseContextABC, bot: DiscordBotServiceABC, ): DataSeederABC.__init__(self) @@ -29,6 +31,7 @@ class LevelSeeder(DataSeederABC): self._levels = level_repo self._servers = servers self._level = level + self._db = db self._bot = bot self._level_header = levels.level_header @@ -51,6 +54,7 @@ class LevelSeeder(DataSeederABC): if levels is None or levels.where(lambda l: l.name == level.name).first_or_default() is None: self._levels.add_level(level) self._logger.debug(__name__, f"Saved level {level.name}") + self._db.save_changes() except discord.errors.Forbidden as e: self._logger.error(__name__, f"Creating level failed", e) level.permissions = 0 -- 2.45.2