Skip to content

Commit ec24dc2

Browse files
Make command_name optional
1 parent 056a138 commit ec24dc2

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

cogs/command_error.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ async def on_application_command_error(
7272
if isinstance(error, discord.ApplicationCommandInvokeError) and isinstance(
7373
error.original, GuildDoesNotExistError
7474
):
75-
command_name: str = (
75+
command_name: str | None = (
7676
(
7777
ctx.command.callback.__name__
7878
if (
@@ -82,7 +82,7 @@ async def on_application_command_error(
8282
else ctx.command.qualified_name
8383
)
8484
if ctx.command
85-
else "UnknownCommand"
85+
else None
8686
)
8787
logger.critical(
8888
" ".join(

utils/tex_bot_base_cog.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ async def command_send_error(
8181
The constructed error message is then sent as the response to the given
8282
application command context.
8383
"""
84-
COMMAND_NAME: Final[str] = (
84+
command_name: str | None = (
8585
(
8686
ctx.command.callback.__name__
8787
if (
@@ -91,13 +91,13 @@ async def command_send_error(
9191
else ctx.command.qualified_name
9292
)
9393
if ctx.command
94-
else "UnknownCommand"
94+
else None
9595
)
9696

9797
await self.send_error(
9898
self.bot,
9999
ctx.interaction,
100-
interaction_name=COMMAND_NAME,
100+
interaction_name=command_name,
101101
error_code=error_code,
102102
message=message,
103103
logging_message=logging_message,
@@ -108,7 +108,7 @@ async def send_error(
108108
cls,
109109
bot: "TeXBot",
110110
interaction: discord.Interaction,
111-
interaction_name: str,
111+
interaction_name: str | None,
112112
error_code: str | None = None,
113113
message: str | None = None,
114114
logging_message: str | BaseException | None = None,
@@ -128,7 +128,7 @@ async def send_error(
128128
f"{error_code}**\n"
129129
) + construct_error_message
130130

131-
if interaction_name in cls.ERROR_ACTIVITIES:
131+
if interaction_name and interaction_name in cls.ERROR_ACTIVITIES:
132132
construct_error_message += (
133133
f" when trying to {cls.ERROR_ACTIVITIES[interaction_name]}"
134134
)

0 commit comments

Comments
 (0)