Improved basic command error handling

This commit is contained in:
2022-07-19 14:12:43 +02:00
parent 47b8af57cd
commit eca67317ad
2 changed files with 13 additions and 5 deletions

View File

@@ -1,4 +1,5 @@
import datetime
import uuid
from cpl_core.time import TimeFormatSettings
from cpl_discord.service import DiscordBotServiceABC
@@ -34,6 +35,8 @@ class BaseOnCommandErrorEvent(OnCommandErrorABC):
async def on_command_error(self, ctx: Context, error: CommandError):
error = getattr(error, 'original', error)
uid = uuid.uuid4()
self._logger.error(__name__, f'Got error: {type(error).__name__} UID: {uid}')
# Todo: translate error messages !!!
if isinstance(error, commands.MissingRequiredArgument):
@@ -130,11 +133,13 @@ class BaseOnCommandErrorEvent(OnCommandErrorABC):
await self._messenger.send_ctx_msg(ctx, 'Fehler: Erweiterung ist fehlgeschlagen!', without_tracking=True)
else:
await self._messenger.send_ctx_msg(ctx, self._t.transform('common.errors.command_error'), without_tracking=True)
message = self._t.transform('modules.base.technician_command_error_message').format(
ctx.command,
ctx.author,
error,
datetime.datetime.now().strftime(self._time_format_settings.date_time_format)
datetime.datetime.now().strftime(self._time_format_settings.date_time_format),
uid
)
for t in self._bot_settings.technicians:
member = self._bot.get_user(t)