Added command checks #114
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import asyncio
|
||||
|
||||
import discord
|
||||
from cpl_core.configuration import ConfigurationABC
|
||||
from cpl_discord.command import DiscordCommandABC
|
||||
from cpl_discord.service import DiscordBotServiceABC
|
||||
@@ -11,6 +10,7 @@ from discord.ext.commands import Context
|
||||
from bot_core.abc.client_utils_service_abc import ClientUtilsServiceABC
|
||||
from bot_core.abc.message_service_abc import MessageServiceABC
|
||||
from bot_core.configuration.bot_settings import BotSettings
|
||||
from bot_core.helper.command_checks import CommandChecks
|
||||
from bot_core.logging.command_logger import CommandLogger
|
||||
from modules.permission.abc.permission_service_abc import PermissionServiceABC
|
||||
|
||||
@@ -43,18 +43,10 @@ class RestartCommand(DiscordCommandABC):
|
||||
|
||||
@commands.hybrid_command()
|
||||
@commands.guild_only()
|
||||
@CommandChecks.check_is_ready()
|
||||
@CommandChecks.check_is_member_moderator()
|
||||
async def restart(self, ctx: Context):
|
||||
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)
|
||||
|
||||
if not self._permissions.is_member_moderator(ctx.author):
|
||||
await self._message_service.send_ctx_msg(ctx, self._t.transform('common.no_permission_message'))
|
||||
self._logger.trace(__name__, f'Finished restart command')
|
||||
return
|
||||
|
||||
self._config.add_configuration('IS_RESTART', 'true')
|
||||
await self._client_utils.presence_game('common.presence.restart')
|
||||
|
@@ -13,6 +13,7 @@ from cpl_discord.events.on_command_error_abc import OnCommandErrorABC
|
||||
|
||||
from bot_core.abc.message_service_abc import MessageServiceABC
|
||||
from bot_core.configuration.bot_settings import BotSettings
|
||||
from bot_core.exception.check_error import CheckError
|
||||
|
||||
|
||||
class BaseOnCommandErrorEvent(OnCommandErrorABC):
|
||||
@@ -35,6 +36,9 @@ class BaseOnCommandErrorEvent(OnCommandErrorABC):
|
||||
self._t = translate
|
||||
|
||||
async def on_command_error(self, ctx: Context, error: CommandError):
|
||||
if isinstance(error, CheckError):
|
||||
return
|
||||
|
||||
error = getattr(error, 'original', error)
|
||||
uid = uuid.uuid4()
|
||||
self._logger.error(__name__, f'Got error: {type(error).__name__} UID: {uid}')
|
||||
|
Reference in New Issue
Block a user