Embedded message in command_not_found
and subcommand_not_found
# ./utils/helper.py
async def subcommand_not_found(self, command: commands.Command, string: str, /) -> None:
if isinstance(command, commands.Group) and len(command.all_commands) > 0:
error_message = f"**Error 404**: Command `{command.qualified_name}` has no subcommand named `{string}`!\n"
error_message += f"\nAvailable subcommands:\n`{'`, `'.join(command.all_commands.keys())}`"
else:
error_message = f"**Error 404**: Command `{command.qualified_name}` has no subcommands!"
channel = self.get_destination()
await channel.send(embed=Embed(description=error_message))
Using the above subcommand_not_found
function to handle subcommand not found raises discord.ext.commands.errors.CommandInvokeError
.
Similarly, command_not_found
is raising the same error when written in a similar manner, i.e.,
# ./utils/helper.py
async def command_not_found(self, string: str, /) -> None:
error_message = f"**Error 404**: Command `{string}` not found!"
channel = self.get_destination()
await channel.send(embed=Embed(description=error_message))
Goal: We want to handle this error and send a response with an embedded message.
Don't forget to read the Contributing Guidelines.