diff --git a/bot/src/bot_core/service/data_integrity_service.py b/bot/src/bot_core/service/data_integrity_service.py index eba805e1..cb3c0f6f 100644 --- a/bot/src/bot_core/service/data_integrity_service.py +++ b/bot/src/bot_core/service/data_integrity_service.py @@ -389,6 +389,19 @@ class DataIntegrityService: for member in guild.members: await self._client_utils.check_default_role(member) + def _check_for_bots(self): + for guild in self._bot.guilds: + server = self._servers.get_server_by_discord_id(guild.id) + + for member in guild.members.where(lambda x: x.bot): + user = self._users.find_user_by_discord_id_and_server_id(member.id, server.id) + if user is None: + continue + + self._user_joins_vc.delete_user_joined_voice_channel_by_user_id(user.id) + self._users.delete_user(user) + self._db_context.save_changes() + async def check_data_integrity(self, is_for_shutdown=False): if is_for_shutdown != self._is_for_shutdown: self._is_for_shutdown = is_for_shutdown @@ -402,3 +415,4 @@ class DataIntegrityService: self._check_user_joins_vc() self._check_user_joined_gs() await self._check_for_user_achievements() + self._check_for_bots() diff --git a/bot/src/modules/base/events/base_on_member_join_event.py b/bot/src/modules/base/events/base_on_member_join_event.py index a09772d6..b3cd2625 100644 --- a/bot/src/modules/base/events/base_on_member_join_event.py +++ b/bot/src/modules/base/events/base_on_member_join_event.py @@ -104,6 +104,8 @@ class BaseOnMemberJoinEvent(OnMemberJoinABC): @EventChecks.check_is_ready() async def on_member_join(self, member: discord.Member): self._logger.debug(__name__, f"Module {type(self)} started") + if member.bot: + return await self._client_utils.check_default_role(member) self._check_for_known_user(member) await self._add_if_not_exists_user_async(member) diff --git a/bot/src/modules/base/events/base_on_voice_state_update_event.py b/bot/src/modules/base/events/base_on_voice_state_update_event.py index 6fb0c113..8815530b 100644 --- a/bot/src/modules/base/events/base_on_voice_state_update_event.py +++ b/bot/src/modules/base/events/base_on_voice_state_update_event.py @@ -97,6 +97,8 @@ class BaseOnVoiceStateUpdateEvent(OnVoiceStateUpdateABC): ) settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{member.guild.id}") server = self._servers.get_server_by_discord_id(member.guild.id) + if member.bot: + return try: if before.channel == after.channel: