forked from sh-edraft.de/sh_discord_bot
Fixed level seeder #28
This commit is contained in:
parent
fe32604a14
commit
faaadb0009
@ -29,14 +29,14 @@ class LevelSeeder(DataSeederABC):
|
|||||||
async def _create_level(self, level: Level, guild: Guild, server: Server):
|
async def _create_level(self, level: Level, guild: Guild, server: Server):
|
||||||
level.server = server
|
level.server = server
|
||||||
try:
|
try:
|
||||||
if guild.roles.where(lambda r: r.name == level.name).first_or_default() is not None:
|
if guild.roles.where(lambda r: r.name == level.name).first_or_default() is None:
|
||||||
return
|
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))
|
levels = self._levels.find_levels_by_server_id(server.server_id)
|
||||||
self._logger.info(__name__, f'Created level {level.name}')
|
if levels is None or levels.where(lambda l: l == level).first_or_default() is None:
|
||||||
|
|
||||||
if self._levels.find_levels_by_server_id(server.server_id).where(lambda l: l == level).first_or_default() is not None:
|
|
||||||
self._levels.add_level(level)
|
self._levels.add_level(level)
|
||||||
|
self._logger.debug(__name__, f'Saved level {level.name}')
|
||||||
except discord.errors.Forbidden as e:
|
except discord.errors.Forbidden as e:
|
||||||
self._logger.error(__name__, f'Creating level failed', e)
|
self._logger.error(__name__, f'Creating level failed', e)
|
||||||
level.permissions = 0
|
level.permissions = 0
|
||||||
|
Loading…
Reference in New Issue
Block a user