Merge pull request 'Der Bot muss wohl zwei mal gestartet werden, damit er die DB richtig läd #214' (#231) from #214 into 1.0.0
Reviewed-on: sh-edraft.de/kd_discord_bot#231 Reviewed-by: Ebola-Chan <nick.jungmann@gmail.com> Closes #214
This commit is contained in:
commit
0f26db3d74
@ -25,10 +25,10 @@ class ModuleList:
|
||||
DataModule,
|
||||
GraphQLModule,
|
||||
PermissionModule,
|
||||
LevelModule,
|
||||
DatabaseModule,
|
||||
AutoRoleModule,
|
||||
BaseModule,
|
||||
LevelModule,
|
||||
ApiModule,
|
||||
TechnicianModule,
|
||||
# has to be last!
|
||||
|
@ -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")
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user