From 9b5033b80e6de327b7cd30f56da4e824023a80e5 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Fri, 18 Nov 2022 14:33:54 +0100 Subject: [PATCH] Fixed some on member join stuff --- kdb-bot/src/bot/module_list.py | 4 ++-- .../events/level_on_member_join_event.py | 23 +++++++++++++++++++ kdb-bot/src/modules/level/level_module.py | 2 ++ 3 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 kdb-bot/src/modules/level/events/level_on_member_join_event.py diff --git a/kdb-bot/src/bot/module_list.py b/kdb-bot/src/bot/module_list.py index cde01ceead..ba6be12770 100644 --- a/kdb-bot/src/bot/module_list.py +++ b/kdb-bot/src/bot/module_list.py @@ -22,11 +22,11 @@ class ModuleList: return List(type, [ CoreModule, # has to be first! DataModule, + PermissionModule, + DatabaseModule, AutoRoleModule, BaseModule, - DatabaseModule, LevelModule, - PermissionModule, ApiModule, StatsModule, TechnicianModule, diff --git a/kdb-bot/src/modules/level/events/level_on_member_join_event.py b/kdb-bot/src/modules/level/events/level_on_member_join_event.py new file mode 100644 index 0000000000..c8ce80ccae --- /dev/null +++ b/kdb-bot/src/modules/level/events/level_on_member_join_event.py @@ -0,0 +1,23 @@ +import discord +from cpl_discord.events import OnMemberJoinABC + +from bot_core.helper.event_checks import EventChecks +from bot_core.logging.message_logger import MessageLogger +from modules.level.service.level_service import LevelService + + +class LevelOnMemberJoinEvent(OnMemberJoinABC): + + def __init__( + self, + logger: MessageLogger, + level: LevelService + ): + OnMemberJoinABC.__init__(self) + self._logger = logger + self._level = level + + @EventChecks.check_is_ready() + async def on_member_join(self, member: discord.Member): + self._logger.debug(__name__, f'Module {type(self)} started') + await self._level.check_level(member) diff --git a/kdb-bot/src/modules/level/level_module.py b/kdb-bot/src/modules/level/level_module.py index aeb57409d0..3502abad93 100644 --- a/kdb-bot/src/modules/level/level_module.py +++ b/kdb-bot/src/modules/level/level_module.py @@ -9,6 +9,7 @@ from cpl_discord.service.discord_collection_abc import DiscordCollectionABC from bot_core.abc.module_abc import ModuleABC from bot_core.configuration.feature_flags_enum import FeatureFlagsEnum from modules.level.command.level_group import LevelGroup +from modules.level.events.level_on_member_join_event import LevelOnMemberJoinEvent from modules.level.events.level_on_message_event import LevelOnMessageEvent from modules.level.events.level_on_voice_state_update_event import LevelOnVoiceStateUpdateEvent from modules.level.level_seeder import LevelSeeder @@ -36,3 +37,4 @@ class LevelModule(ModuleABC): # events self._dc.add_event(DiscordEventTypesEnum.on_message.value, LevelOnMessageEvent) self._dc.add_event(DiscordEventTypesEnum.on_voice_state_update.value, LevelOnVoiceStateUpdateEvent) + self._dc.add_event(DiscordEventTypesEnum.on_member_join.value, LevelOnMemberJoinEvent)