Reputation: 307
I was trying to Error Handling with this code
@mute.error
async def mute_error(ctx, error):
and It has given me this TypeError when it runs
TypeError: mute_error() takes 2 positional arguments but 3 were given
I think this error is caused by those 2 lines but if not here is the rest of the error handling code:
@mute.error
async def mute_error(ctx, error):
if isinstance(error, commands.MissingPermissions):
await ctx.send(f'{ctx.message.author.mention} You do not have the permission to run that command! :red_circle:')
elif isinstance(error, commands.MissingRequiredArgument):
await ctx.send(f'{ctx.message.author.mention} There is an Argument missing in that command! :red_circle:\nMute Command Syntax: wm>mute @user [reason]')
elif isinstance(error, commands.BadArgument):
await ctx.send(f'{ctx.message.author.mention} To mute someone you need to mention them! :red_circle:\nMute Command Syntax: wm>mute @user [reason]')
else:
await ctx.send('There was an error while executing the command! xxLandiPlayz has been informed! :red_circle:')
print(error)
It is also inside a Cog, inside the Mod class
class Mod(commands.Cog):
def __init__(self, bot):
self.bot = bot
What am I doing wrong here?
Thanks in advance!
Upvotes: 0
Views: 966
Reputation:
When I used this I have first parameter after self
is error
, second is ctx
. You can use the same order of parameters if you have some problems with use of parameters.
For your problem, may be it's help if you use this method in class:
@mute.error
async def mute_error(self, error, ctx):
Upvotes: 2