How do I make an error response for a specific command on a cog discord.py

I have a kick command in a cog and it works. But the error event that I put for the kick command triggers all the other error events that I have set up in my other cogs. For example, I have a ban command (ban.py) and a kick command (kick.py). each have their own code for the error event like the code below. But I want them to have its own error like @kick.error or @ban.error because when I get an error on one of the commands, it shows the error for both of them. But sadly @kick.error or @ban.error doesn't work in cogs. Please help me fix this.

@commands.Cog.listener()
async def on_command _error(self, ctx, error):
   if isinstance(error, commands.MissingRequiredArgument):
        await ctx.send('(text here)')
    if isinstance(error, commands.MissingPermissions):
        await ctx.send("(text here)")


Read more here: https://stackoverflow.com/questions/67926672/how-do-i-make-an-error-response-for-a-specific-command-on-a-cog-discord-py

Content Attribution

This content was originally published by Brandon Figueroa at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: