0.3 - level down (#28) #98

Merged
edraft merged 4 commits from #28 into 0.3 2022-11-09 10:03:22 +01:00
Showing only changes of commit faaadb0009 - Show all commits

View File

@ -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