'Discord.py discord_slash libary cogs error handling
I have one command, but i wanted add a permission, if the guy who dont have permission for banning user the slash send "you dont have a permission for this" I try use:
@setlang.error
async def cog_command_error(self, ctx, error):
if isinstance(error, commands.MissingPermissions):
await ctx.send("You dont have all permission for this command")
But the output is: discord.ext.commands.errors.ExtensionFailed: Extension 'cogs.Utility' raised an error: AttributeError: 'CogCommandObject' object has no attribute 'error'
Libary: discord.py / discord_slash (in Cog)
Code:
@cog_ext.cog_slash(name="serverlog",description="Server Log Channel")
@has_permissions(ban_members=True)
async def _serverlog(self, ctx, channel: discord.TextChannel = None):
(code)
@_serverlog.error
async def cog_command_error(self, ctx, error):
if isinstance(error, commands.MissingPermissions):
await ctx.send("You dont have all permission for this command")
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
