Fixed notification on OnMemberJoin #191
This commit is contained in:
parent
c0882a8ad3
commit
1f3b12501b
@ -57,6 +57,7 @@ class LevelService:
|
|||||||
if level_role in member.roles:
|
if level_role in member.roles:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
notification_needed = False
|
||||||
for role in member.roles:
|
for role in member.roles:
|
||||||
if role.name not in level_names.to_list():
|
if role.name not in level_names.to_list():
|
||||||
continue
|
continue
|
||||||
@ -64,6 +65,7 @@ class LevelService:
|
|||||||
try:
|
try:
|
||||||
self._logger.debug(__name__, f"Try to remove role {role.name} from {member.name}")
|
self._logger.debug(__name__, f"Try to remove role {role.name} from {member.name}")
|
||||||
await member.remove_roles(role)
|
await member.remove_roles(role)
|
||||||
|
notification_needed = True
|
||||||
self._logger.info(__name__, f"Removed role {role.name} from {member.name}")
|
self._logger.info(__name__, f"Removed role {role.name} from {member.name}")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self._logger.error(__name__, f"Removing role {role.name} from {member.name} failed!", e)
|
self._logger.error(__name__, f"Removing role {role.name} from {member.name} failed!", e)
|
||||||
@ -75,6 +77,7 @@ class LevelService:
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
self._logger.error(__name__, f"Adding role {level_role.name} to {member.name} failed!", e)
|
self._logger.error(__name__, f"Adding role {level_role.name} to {member.name} failed!", e)
|
||||||
|
|
||||||
|
if notification_needed:
|
||||||
level_settings: LevelServerSettings = self._config.get_configuration(f"LevelServerSettings_{guild.id}")
|
level_settings: LevelServerSettings = self._config.get_configuration(f"LevelServerSettings_{guild.id}")
|
||||||
await self._message_service.send_channel_message(
|
await self._message_service.send_channel_message(
|
||||||
self._bot.get_channel(level_settings.changed_level_notification_channel),
|
self._bot.get_channel(level_settings.changed_level_notification_channel),
|
||||||
|
Loading…
Reference in New Issue
Block a user