From e47318d8e9236f83d68a8fbc17901f5abcc33493 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Wed, 9 Nov 2022 22:21:32 +0100 Subject: [PATCH] Added received command to new commands #105 --- .../src/modules/auto_role/command/auto_role_group.py | 6 ++++++ kdb-bot/src/modules/base/command/purge_command.py | 1 - kdb-bot/src/modules/base/command/restart_command.py | 1 + kdb-bot/src/modules/base/command/shutdown_command.py | 1 + kdb-bot/src/modules/level/command/level_group.py | 12 ++++++++---- kdb-bot/src/modules/stats/command/stats_group.py | 5 +++++ 6 files changed, 21 insertions(+), 5 deletions(-) diff --git a/kdb-bot/src/modules/auto_role/command/auto_role_group.py b/kdb-bot/src/modules/auto_role/command/auto_role_group.py index 515d2fe4..62667069 100644 --- a/kdb-bot/src/modules/auto_role/command/auto_role_group.py +++ b/kdb-bot/src/modules/auto_role/command/auto_role_group.py @@ -60,6 +60,7 @@ class AutoRoleGroup(DiscordCommandABC): self._logger.debug(__name__, f'Received command auto-role list {ctx}') if not await self._client_utils.check_if_bot_is_ready_yet_and_respond(ctx): return + self._client_utils.received_command(ctx.guild.id) if not self._permissions.is_member_moderator(ctx.author): await self._message_service.send_ctx_msg(ctx, self._t.transform('common.no_permission_message')) @@ -94,6 +95,7 @@ class AutoRoleGroup(DiscordCommandABC): self._logger.debug(__name__, f'Received command auto-role add {ctx} {message_id}') if not await self._client_utils.check_if_bot_is_ready_yet_and_respond(ctx): return + self._client_utils.received_command(ctx.guild.id) if not self._permissions.is_member_moderator(ctx.author): await self._message_service.send_ctx_msg(ctx, self._t.transform('common.no_permission_message')) @@ -140,6 +142,7 @@ class AutoRoleGroup(DiscordCommandABC): self._logger.debug(__name__, f'Received command auto-role remove {ctx} {auto_role}') if not await self._client_utils.check_if_bot_is_ready_yet_and_respond(ctx): return + self._client_utils.received_command(ctx.guild.id) if not self._permissions.is_member_moderator(ctx.author): await self._message_service.send_ctx_msg(ctx, self._t.transform('common.no_permission_message')) @@ -179,6 +182,7 @@ class AutoRoleGroup(DiscordCommandABC): self._logger.debug(__name__, f'Received command auto-role rule list {ctx}') if not await self._client_utils.check_if_bot_is_ready_yet_and_respond(ctx): return + self._client_utils.received_command(ctx.guild.id) if not self._permissions.is_member_moderator(ctx.author): await self._message_service.send_ctx_msg(ctx, self._t.transform('common.no_permission_message')) @@ -221,6 +225,7 @@ class AutoRoleGroup(DiscordCommandABC): self._logger.debug(__name__, f'Received command auto-role add {ctx} {auto_role}') if not await self._client_utils.check_if_bot_is_ready_yet_and_respond(ctx): return + self._client_utils.received_command(ctx.guild.id) if not self._permissions.is_member_moderator(ctx.author): await self._message_service.send_ctx_msg(ctx, self._t.transform('common.no_permission_message')) @@ -278,6 +283,7 @@ class AutoRoleGroup(DiscordCommandABC): self._logger.debug(__name__, f'Received command auto-role remove {ctx} {auto_role_rule}') if not await self._client_utils.check_if_bot_is_ready_yet_and_respond(ctx): return + self._client_utils.received_command(ctx.guild.id) if not self._permissions.is_member_moderator(ctx.author): await self._message_service.send_ctx_msg(ctx, self._t.transform('common.no_permission_message')) diff --git a/kdb-bot/src/modules/base/command/purge_command.py b/kdb-bot/src/modules/base/command/purge_command.py index 6599f59a..11b90c22 100644 --- a/kdb-bot/src/modules/base/command/purge_command.py +++ b/kdb-bot/src/modules/base/command/purge_command.py @@ -41,7 +41,6 @@ class PurgeCommand(DiscordCommandABC): self._logger.debug(__name__, f'Received command purge {ctx}') if not await self._client_utils.check_if_bot_is_ready_yet_and_respond(ctx): return - self._client_utils.received_command(ctx.guild.id) server_settings: ServerSettings = self._config.get_configuration(f'ServerSettings_{ctx.guild.id}') diff --git a/kdb-bot/src/modules/base/command/restart_command.py b/kdb-bot/src/modules/base/command/restart_command.py index 179eeceb..56c48958 100644 --- a/kdb-bot/src/modules/base/command/restart_command.py +++ b/kdb-bot/src/modules/base/command/restart_command.py @@ -47,6 +47,7 @@ class RestartCommand(DiscordCommandABC): self._logger.debug(__name__, f'Received command restart {ctx}') if not await self._client_utils.check_if_bot_is_ready_yet_and_respond(ctx): return + self._client_utils.received_command(ctx.guild.id) self._client_utils.received_command(ctx.guild.id) diff --git a/kdb-bot/src/modules/base/command/shutdown_command.py b/kdb-bot/src/modules/base/command/shutdown_command.py index 0fe0f5fb..e2541e8d 100644 --- a/kdb-bot/src/modules/base/command/shutdown_command.py +++ b/kdb-bot/src/modules/base/command/shutdown_command.py @@ -47,6 +47,7 @@ class ShutdownCommand(DiscordCommandABC): self._logger.debug(__name__, f'Received command shutdown {ctx}') if not await self._client_utils.check_if_bot_is_ready_yet_and_respond(ctx): return + self._client_utils.received_command(ctx.guild.id) self._client_utils.received_command(ctx.guild.id) diff --git a/kdb-bot/src/modules/level/command/level_group.py b/kdb-bot/src/modules/level/command/level_group.py index 32ccb708..7a49593c 100644 --- a/kdb-bot/src/modules/level/command/level_group.py +++ b/kdb-bot/src/modules/level/command/level_group.py @@ -78,6 +78,7 @@ class LevelGroup(DiscordCommandABC): self._logger.debug(__name__, f'Received command level list {ctx}') if not await self._client_utils.check_if_bot_is_ready_yet_and_respond(ctx): return + self._client_utils.received_command(ctx.guild.id) if not self._permissions.is_member_moderator(ctx.author): await self._message_service.send_ctx_msg(ctx, self._t.transform('common.no_permission_message')) @@ -117,6 +118,9 @@ class LevelGroup(DiscordCommandABC): @commands.guild_only() async def create(self, ctx: Context, name: str, color: str, min_xp: int, permissions: int): self._logger.debug(__name__, f'Received command level create {ctx}') + if not await self._client_utils.check_if_bot_is_ready_yet_and_respond(ctx): + return + self._client_utils.received_command(ctx.guild.id) try: color = hex(discord.Colour.from_str(color).value) @@ -130,9 +134,6 @@ class LevelGroup(DiscordCommandABC): self._logger.error(__name__, f'Error parsing permissions {permissions}', e) return - if not await self._client_utils.check_if_bot_is_ready_yet_and_respond(ctx): - return - if ctx.guild is None: return @@ -194,9 +195,9 @@ class LevelGroup(DiscordCommandABC): @commands.guild_only() async def remove(self, ctx: Context, level: str): self._logger.debug(__name__, f'Received command level remove {ctx}') - if not await self._client_utils.check_if_bot_is_ready_yet_and_respond(ctx): return + self._client_utils.received_command(ctx.guild.id) if not self._permissions.is_member_admin(ctx.author): await self._message_service.send_ctx_msg(ctx, self._t.transform('common.no_permission_message')) @@ -243,6 +244,7 @@ class LevelGroup(DiscordCommandABC): self._logger.debug(__name__, f'Received command level down {ctx} {member}') if not await self._client_utils.check_if_bot_is_ready_yet_and_respond(ctx): return + self._client_utils.received_command(ctx.guild.id) if not self._permissions.is_member_moderator(ctx.author): await self._message_service.send_ctx_msg(ctx, self._t.transform('common.no_permission_message')) @@ -284,6 +286,7 @@ class LevelGroup(DiscordCommandABC): self._logger.debug(__name__, f'Received command level up {ctx} {member}') if not await self._client_utils.check_if_bot_is_ready_yet_and_respond(ctx): return + self._client_utils.received_command(ctx.guild.id) if not self._permissions.is_member_moderator(ctx.author): await self._message_service.send_ctx_msg(ctx, self._t.transform('common.no_permission_message')) @@ -325,6 +328,7 @@ class LevelGroup(DiscordCommandABC): self._logger.debug(__name__, f'Received command level up {ctx} {member}') if not await self._client_utils.check_if_bot_is_ready_yet_and_respond(ctx): return + self._client_utils.received_command(ctx.guild.id) if not self._permissions.is_member_moderator(ctx.author): await self._message_service.send_ctx_msg(ctx, self._t.transform('common.no_permission_message')) diff --git a/kdb-bot/src/modules/stats/command/stats_group.py b/kdb-bot/src/modules/stats/command/stats_group.py index 89abcb57..41d40c5e 100644 --- a/kdb-bot/src/modules/stats/command/stats_group.py +++ b/kdb-bot/src/modules/stats/command/stats_group.py @@ -55,6 +55,7 @@ class StatsGroup(DiscordCommandABC): self._logger.debug(__name__, f'Received command stats list {ctx}') if not await self._client_utils.check_if_bot_is_ready_yet_and_respond(ctx): return + self._client_utils.received_command(ctx.guild.id) if not self._permissions.is_member_moderator(ctx.author): await self._message_service.send_ctx_msg(ctx, self._t.transform('common.no_permission_message')) @@ -94,6 +95,7 @@ class StatsGroup(DiscordCommandABC): self._logger.debug(__name__, f'Received command stats view {ctx}:{name}') if not await self._client_utils.check_if_bot_is_ready_yet_and_respond(ctx): return + self._client_utils.received_command(ctx.guild.id) if not self._permissions.is_member_moderator(ctx.author): await self._message_service.send_ctx_msg(ctx, self._t.transform('common.no_permission_message')) @@ -141,6 +143,7 @@ class StatsGroup(DiscordCommandABC): self._logger.debug(__name__, f'Received command stats add {ctx}: {name}') if not await self._client_utils.check_if_bot_is_ready_yet_and_respond(ctx): return + self._client_utils.received_command(ctx.guild.id) if not self._permissions.is_member_technician(ctx.author): await self._message_service.send_ctx_msg(ctx, self._t.transform('common.no_permission_message')) @@ -162,6 +165,7 @@ class StatsGroup(DiscordCommandABC): self._logger.debug(__name__, f'Received command stats edit {ctx}: {name}') if not await self._client_utils.check_if_bot_is_ready_yet_and_respond(ctx): return + self._client_utils.received_command(ctx.guild.id) if not self._permissions.is_member_technician(ctx.author): await self._message_service.send_ctx_msg(ctx, self._t.transform('common.no_permission_message')) @@ -192,6 +196,7 @@ class StatsGroup(DiscordCommandABC): self._logger.debug(__name__, f'Received command stats remove {ctx}: {name}') if not await self._client_utils.check_if_bot_is_ready_yet_and_respond(ctx): return + self._client_utils.received_command(ctx.guild.id) if not self._permissions.is_member_technician(ctx.author): await self._message_service.send_ctx_msg(ctx, self._t.transform('common.no_permission_message')) -- 2.45.2