From faaadb000914575544ec75c8395e1241015fcf34 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Tue, 8 Nov 2022 17:49:42 +0100 Subject: [PATCH] Fixed level seeder #28 --- kdb-bot/src/modules/level/level_seeder.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/kdb-bot/src/modules/level/level_seeder.py b/kdb-bot/src/modules/level/level_seeder.py index 870a7b30..2b4fc643 100644 --- a/kdb-bot/src/modules/level/level_seeder.py +++ b/kdb-bot/src/modules/level/level_seeder.py @@ -29,14 +29,14 @@ class LevelSeeder(DataSeederABC): async def _create_level(self, level: Level, guild: Guild, server: Server): level.server = server try: - if guild.roles.where(lambda r: r.name == level.name).first_or_default() is not None: - return + if guild.roles.where(lambda r: r.name == level.name).first_or_default() is None: + await guild.create_role(name=level.name, colour=Colour(int(level.color, 16)), hoist=False, mentionable=True, permissions=Permissions(level.permissions)) + self._logger.debug(__name__, f'Created role {level.name}') - await guild.create_role(name=level.name, colour=Colour(int(level.color, 16)), hoist=False, mentionable=True, permissions=Permissions(level.permissions)) - self._logger.info(__name__, f'Created level {level.name}') - - if self._levels.find_levels_by_server_id(server.server_id).where(lambda l: l == level).first_or_default() is not None: + levels = self._levels.find_levels_by_server_id(server.server_id) + if levels is None or levels.where(lambda l: l == level).first_or_default() is None: self._levels.add_level(level) + self._logger.debug(__name__, f'Saved level {level.name}') except discord.errors.Forbidden as e: self._logger.error(__name__, f'Creating level failed', e) level.permissions = 0