Add custom error text for CommandNotFound

This commit is contained in:
JelNiSlaw 2022-12-07 20:34:44 +01:00
parent 34e5ebab57
commit 333a3d4a62
No known key found for this signature in database
GPG key ID: EA41571A0A88E97E

View file

@ -12,7 +12,7 @@ class Wulkabot(commands.Bot):
def __init__(self) -> None: def __init__(self) -> None:
super().__init__( super().__init__(
command_prefix=commands.when_mentioned_or("!"), command_prefix=commands.when_mentioned_or("!"),
help_command=commands.MinimalHelpCommand(), help_command=None,
intents=discord.Intents(guilds=True, messages=True, message_content=True), intents=discord.Intents(guilds=True, messages=True, message_content=True),
allowed_mentions=discord.AllowedMentions.none(), allowed_mentions=discord.AllowedMentions.none(),
) )
@ -27,7 +27,10 @@ class Wulkabot(commands.Bot):
async def on_command_error( async def on_command_error(
self, context: commands.Context, exception: commands.errors.CommandError, / self, context: commands.Context, exception: commands.errors.CommandError, /
) -> None: ) -> None:
await context.send(f"Error! {exception}") if isinstance(exception, commands.CommandNotFound):
await context.send("Taka komenda nie istnieje. Być może chcesz użyć jej wersji z `/`")
else:
await context.send(str(exception))
async def close(self) -> None: async def close(self) -> None:
await super().close() await super().close()