From 232429a77dbc216d675e46745971f73003c48561 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Fri, 13 Oct 2023 15:24:02 +0200 Subject: [PATCH] Updated cpl-discord #404 --- kdb-bot/src/bot/bot.json | 2 +- kdb-bot/src/bot_api/api_module.py | 2 +- .../core_extension/core_extension_module.py | 2 +- kdb-bot/src/bot_core/core_module.py | 2 +- .../achievements/achievements_module.py | 10 ++-- .../src/modules/auto_role/auto_role_module.py | 6 +-- kdb-bot/src/modules/base/base_module.py | 52 +++++++++---------- .../src/modules/boot_log/boot_log_module.py | 2 +- kdb-bot/src/modules/config/config_module.py | 2 +- .../src/modules/database/database_module.py | 2 +- kdb-bot/src/modules/level/level_module.py | 12 ++--- .../short_role_name/short_role_name_module.py | 4 +- .../modules/technician/technician_module.py | 10 ++-- 13 files changed, 54 insertions(+), 54 deletions(-) diff --git a/kdb-bot/src/bot/bot.json b/kdb-bot/src/bot/bot.json index c7bbec88..f732df34 100644 --- a/kdb-bot/src/bot/bot.json +++ b/kdb-bot/src/bot/bot.json @@ -19,7 +19,7 @@ "cpl-core==2023.10.0", "cpl-translation==2023.4.0.post1", "cpl-query==2023.10.0", - "cpl-discord==2023.10.0", + "cpl-discord==2023.10.0.post1", "Flask==3.0.0", "Flask-Classful==0.16.0", "Flask-Cors==4.0.0", diff --git a/kdb-bot/src/bot_api/api_module.py b/kdb-bot/src/bot_api/api_module.py index 8f40f95e..b2695e12 100644 --- a/kdb-bot/src/bot_api/api_module.py +++ b/kdb-bot/src/bot_api/api_module.py @@ -48,4 +48,4 @@ class ApiModule(ModuleABC): services.add_transient(GraphQLController) # cpl-discord - self._dc.add_event(DiscordEventTypesEnum.on_ready.value, BotApiOnReadyEvent) + services.add_transient(DiscordEventTypesEnum.on_ready.value, BotApiOnReadyEvent) diff --git a/kdb-bot/src/bot_core/core_extension/core_extension_module.py b/kdb-bot/src/bot_core/core_extension/core_extension_module.py index d6cba99b..ef16529f 100644 --- a/kdb-bot/src/bot_core/core_extension/core_extension_module.py +++ b/kdb-bot/src/bot_core/core_extension/core_extension_module.py @@ -19,4 +19,4 @@ class CoreExtensionModule(ModuleABC): pass def configure_services(self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC): - self._dc.add_event(DiscordEventTypesEnum.on_ready.value, CoreExtensionOnReadyEvent) + services.add_transient(DiscordEventTypesEnum.on_ready.value, CoreExtensionOnReadyEvent) diff --git a/kdb-bot/src/bot_core/core_module.py b/kdb-bot/src/bot_core/core_module.py index fcb06333..02611684 100644 --- a/kdb-bot/src/bot_core/core_module.py +++ b/kdb-bot/src/bot_core/core_module.py @@ -32,4 +32,4 @@ class CoreModule(ModuleABC): # pipes services.add_transient(DateTimeOffsetPipe) - self._dc.add_event(DiscordEventTypesEnum.on_ready.value, CoreOnReadyEvent) + services.add_transient(DiscordEventTypesEnum.on_ready.value, CoreOnReadyEvent) diff --git a/kdb-bot/src/modules/achievements/achievements_module.py b/kdb-bot/src/modules/achievements/achievements_module.py index 3860feac..8ea61396 100644 --- a/kdb-bot/src/modules/achievements/achievements_module.py +++ b/kdb-bot/src/modules/achievements/achievements_module.py @@ -26,9 +26,9 @@ class AchievementsModule(ModuleABC): services.add_transient(AchievementAttributeResolver) services.add_transient(AchievementService) - self._dc.add_command(AchievementGroup) + services.add_transient(AchievementGroup) - self._dc.add_event(DiscordEventTypesEnum.on_message.value, AchievementOnMessageEvent) - self._dc.add_event(DiscordEventTypesEnum.on_reaction_add.value, AchievementOnReactionAddEvent) - self._dc.add_event(DiscordEventTypesEnum.on_reaction_remove.value, AchievementOnReactionRemoveEvent) - self._dc.add_event(DiscordEventTypesEnum.on_voice_state_update.value, AchievementOnVoiceStateUpdateEvent) + services.add_transient(DiscordEventTypesEnum.on_message.value, AchievementOnMessageEvent) + services.add_transient(DiscordEventTypesEnum.on_reaction_add.value, AchievementOnReactionAddEvent) + services.add_transient(DiscordEventTypesEnum.on_reaction_remove.value, AchievementOnReactionRemoveEvent) + services.add_transient(DiscordEventTypesEnum.on_voice_state_update.value, AchievementOnVoiceStateUpdateEvent) diff --git a/kdb-bot/src/modules/auto_role/auto_role_module.py b/kdb-bot/src/modules/auto_role/auto_role_module.py index e23085f3..07eba97e 100644 --- a/kdb-bot/src/modules/auto_role/auto_role_module.py +++ b/kdb-bot/src/modules/auto_role/auto_role_module.py @@ -26,13 +26,13 @@ class AutoRoleModule(ModuleABC): def configure_services(self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC): services.add_transient(AutoRoleReactionHandler) # commands - self._dc.add_command(AutoRoleGroup) + services.add_transient(AutoRoleGroup) # events - self._dc.add_event( + services.add_transient( DiscordEventTypesEnum.on_raw_reaction_add.value, AutoRoleOnRawReactionAddEvent, ) - self._dc.add_event( + services.add_transient( DiscordEventTypesEnum.on_raw_reaction_remove.value, AutoRoleOnRawReactionRemoveEvent, ) diff --git a/kdb-bot/src/modules/base/base_module.py b/kdb-bot/src/modules/base/base_module.py index 949fa4ad..e7d597a9 100644 --- a/kdb-bot/src/modules/base/base_module.py +++ b/kdb-bot/src/modules/base/base_module.py @@ -65,49 +65,49 @@ class BaseModule(ModuleABC): services.add_transient(ComplaintForm) # commands - self._dc.add_command(AFKCommand) - self._dc.add_command(SubmitGroup) - self._dc.add_command(HelpCommand) - self._dc.add_command(InfoCommand) - self._dc.add_command(MassMoveCommand) - self._dc.add_command(PingCommand) - self._dc.add_command(PresenceCommand) - self._dc.add_command(MakeCoffeeCommand) + services.add_transient(AFKCommand) + services.add_transient(SubmitGroup) + services.add_transient(HelpCommand) + services.add_transient(InfoCommand) + services.add_transient(MassMoveCommand) + services.add_transient(PingCommand) + services.add_transient(PresenceCommand) + services.add_transient(MakeCoffeeCommand) - self._dc.add_command(PurgeCommand) - self._dc.add_command(UserGroup) - self._dc.add_command(RegisterGroup) - self._dc.add_command(UnregisterGroup) - self._dc.add_command(GameServerGroup) + services.add_transient(PurgeCommand) + services.add_transient(UserGroup) + services.add_transient(RegisterGroup) + services.add_transient(UnregisterGroup) + services.add_transient(GameServerGroup) # events - self._dc.add_event(DiscordEventTypesEnum.on_command.value, BaseOnCommandEvent) - self._dc.add_event(DiscordEventTypesEnum.on_command_error.value, BaseOnCommandErrorEvent) - self._dc.add_event(DiscordEventTypesEnum.on_member_join.value, BaseOnMemberJoinEvent) - self._dc.add_event(DiscordEventTypesEnum.on_member_remove.value, BaseOnMemberRemoveEvent) - self._dc.add_event(DiscordEventTypesEnum.on_message.value, BaseOnMessageEvent) - self._dc.add_event(DiscordEventTypesEnum.on_message_delete.value, BaseOnMessageDeleteEvent) - self._dc.add_event(DiscordEventTypesEnum.on_raw_reaction_add.value, BaseOnRawReactionAddEvent) - self._dc.add_event( + services.add_transient(DiscordEventTypesEnum.on_command.value, BaseOnCommandEvent) + services.add_transient(DiscordEventTypesEnum.on_command_error.value, BaseOnCommandErrorEvent) + services.add_transient(DiscordEventTypesEnum.on_member_join.value, BaseOnMemberJoinEvent) + services.add_transient(DiscordEventTypesEnum.on_member_remove.value, BaseOnMemberRemoveEvent) + services.add_transient(DiscordEventTypesEnum.on_message.value, BaseOnMessageEvent) + services.add_transient(DiscordEventTypesEnum.on_message_delete.value, BaseOnMessageDeleteEvent) + services.add_transient(DiscordEventTypesEnum.on_raw_reaction_add.value, BaseOnRawReactionAddEvent) + services.add_transient( DiscordEventTypesEnum.on_raw_reaction_remove.value, BaseOnRawReactionRemoveEvent, ) - self._dc.add_event( + services.add_transient( DiscordEventTypesEnum.on_voice_state_update.value, BaseOnVoiceStateUpdateEvent, ) - self._dc.add_event( + services.add_transient( DiscordEventTypesEnum.on_voice_state_update.value, BaseOnVoiceStateUpdateEventHelpChannel, ) - self._dc.add_event( + services.add_transient( DiscordEventTypesEnum.on_voice_state_update.value, BaseOnVoiceStateUpdateEventScheduledEventBonus, ) - self._dc.add_event( + services.add_transient( DiscordEventTypesEnum.on_scheduled_event_update.value, BaseOnScheduledEventUpdateEvent, ) - self._dc.add_event( + services.add_transient( DiscordEventTypesEnum.on_guild_join.value, BaseOnGuildJoinEvent, ) diff --git a/kdb-bot/src/modules/boot_log/boot_log_module.py b/kdb-bot/src/modules/boot_log/boot_log_module.py index 94a1cc14..dde842f0 100644 --- a/kdb-bot/src/modules/boot_log/boot_log_module.py +++ b/kdb-bot/src/modules/boot_log/boot_log_module.py @@ -19,4 +19,4 @@ class BootLogModule(ModuleABC): def configure_services(self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC): # commands # events - self._dc.add_event(DiscordEventTypesEnum.on_ready.value, BootLogOnReadyEvent) + services.add_transient(DiscordEventTypesEnum.on_ready.value, BootLogOnReadyEvent) diff --git a/kdb-bot/src/modules/config/config_module.py b/kdb-bot/src/modules/config/config_module.py index c55b62d1..14c16263 100644 --- a/kdb-bot/src/modules/config/config_module.py +++ b/kdb-bot/src/modules/config/config_module.py @@ -17,4 +17,4 @@ class ConfigModule(ModuleABC): pass def configure_services(self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC): - self._dc.add_event(DiscordEventTypesEnum.on_ready.value, ConfigOnReadyEvent) + services.add_transient(DiscordEventTypesEnum.on_ready.value, ConfigOnReadyEvent) diff --git a/kdb-bot/src/modules/database/database_module.py b/kdb-bot/src/modules/database/database_module.py index cf478645..bd7c6c6f 100644 --- a/kdb-bot/src/modules/database/database_module.py +++ b/kdb-bot/src/modules/database/database_module.py @@ -19,4 +19,4 @@ class DatabaseModule(ModuleABC): def configure_services(self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC): # commands # events - self._dc.add_event(DiscordEventTypesEnum.on_ready.value, DatabaseOnReadyEvent) + services.add_transient(DiscordEventTypesEnum.on_ready.value, DatabaseOnReadyEvent) diff --git a/kdb-bot/src/modules/level/level_module.py b/kdb-bot/src/modules/level/level_module.py index 018377f9..fced470c 100644 --- a/kdb-bot/src/modules/level/level_module.py +++ b/kdb-bot/src/modules/level/level_module.py @@ -36,14 +36,14 @@ class LevelModule(ModuleABC): services.add_transient(LevelService) # commands - self._dc.add_command(LevelGroup) + services.add_transient(LevelGroup) # events - self._dc.add_event(DiscordEventTypesEnum.on_message.value, LevelOnMessageEvent) - self._dc.add_event( + services.add_transient(DiscordEventTypesEnum.on_message.value, LevelOnMessageEvent) + services.add_transient( DiscordEventTypesEnum.on_voice_state_update.value, LevelOnVoiceStateUpdateEvent, ) - self._dc.add_event(DiscordEventTypesEnum.on_member_join.value, LevelOnMemberJoinEvent) - self._dc.add_event(DiscordEventTypesEnum.on_raw_reaction_add.value, LevelOnRawReactionAddEvent) - self._dc.add_event(DiscordEventTypesEnum.on_raw_reaction_remove.value, LevelOnRawReactionRemoveEvent) + services.add_transient(DiscordEventTypesEnum.on_member_join.value, LevelOnMemberJoinEvent) + services.add_transient(DiscordEventTypesEnum.on_raw_reaction_add.value, LevelOnRawReactionAddEvent) + services.add_transient(DiscordEventTypesEnum.on_raw_reaction_remove.value, LevelOnRawReactionRemoveEvent) diff --git a/kdb-bot/src/modules/short_role_name/short_role_name_module.py b/kdb-bot/src/modules/short_role_name/short_role_name_module.py index 3a413eb1..6eff2a02 100644 --- a/kdb-bot/src/modules/short_role_name/short_role_name_module.py +++ b/kdb-bot/src/modules/short_role_name/short_role_name_module.py @@ -25,6 +25,6 @@ class ShortRoleNameModule(ModuleABC): services.add_transient(ShortRoleNameService) # commands - self._dc.add_command(ShortRoleNameCheckCommand) + services.add_transient(ShortRoleNameCheckCommand) # events - self._dc.add_event(DiscordEventTypesEnum.on_member_update.value, ShortRoleNameOnMemberUpdateEvent) + services.add_transient(DiscordEventTypesEnum.on_member_update.value, ShortRoleNameOnMemberUpdateEvent) diff --git a/kdb-bot/src/modules/technician/technician_module.py b/kdb-bot/src/modules/technician/technician_module.py index 5d5472ba..8550b7d6 100644 --- a/kdb-bot/src/modules/technician/technician_module.py +++ b/kdb-bot/src/modules/technician/technician_module.py @@ -24,9 +24,9 @@ class TechnicianModule(ModuleABC): def configure_services(self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC): services.add_transient(DataSeederABC, ApiKeySeeder) # commands - self._dc.add_command(RestartCommand) - self._dc.add_command(ShutdownCommand) - self._dc.add_command(LogCommand) - self._dc.add_command(ApiKeyGroup) - self._dc.add_command(SyncXpGroup) + services.add_transient(RestartCommand) + services.add_transient(ShutdownCommand) + services.add_transient(LogCommand) + services.add_transient(ApiKeyGroup) + services.add_transient(SyncXpGroup) # events