From 414720f53bf015781b0284e68fdfeeafe1f796cf Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Mon, 12 Feb 2024 14:19:31 +0100 Subject: [PATCH] Update level permission by db state on level seeding --- bot/src/modules/level/level_seeder.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bot/src/modules/level/level_seeder.py b/bot/src/modules/level/level_seeder.py index 19c7b773..9d30c0e8 100644 --- a/bot/src/modules/level/level_seeder.py +++ b/bot/src/modules/level/level_seeder.py @@ -104,7 +104,8 @@ class LevelSeeder(DataSeederABC): levels = levels.order_by_descending(lambda l: l.min_xp) position_above_levels = guild.roles.where(lambda r: r.name == self._level_header).single().position for role in guild.roles.order_by_descending(lambda r: r.position): - if levels.where(lambda l: l.name == role.name).count() == 0: + level = levels.where(lambda l: l.name == role.name).first_or_default() + if level is None: continue new_position = position_above_levels - ( @@ -117,7 +118,7 @@ class LevelSeeder(DataSeederABC): __name__, f"Moved {role.name} from {role.position} to {new_position}", ) - await role.edit(position=new_position) + await role.edit(permissions=level.permissions, position=new_position) except Exception as e: self._logger.error(__name__, f"Cannot change position of {role.name}", e)