尝试在没有禁止权限的情况下禁止用户时出错



我得到:

discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: ban_error() takes 2 positional arguments but 3 were given

每当我尝试使用此命令时:(我用的是齿轮(

@commands.command(name="ban", pass_context=True)
@has_permissions(ban_members=True)
async def _ban(self, ctx, member : discord.Member = None, *, reason:str = None):
if member == None:
await ctx.send("Please mention a user.")
if reason == None:
reason = "N/A"
else:
ban=discord.Embed(title=f"You have been banned from {ctx.guild.name}", color=0x61187c)
ban.add_field(name="Reason:", value=f"{reason}", inline=True)
ban.set_footer(text="( ͡° ͜ʖ ͡°)")
await member.send(embed=ban)
embed=discord.Embed(title=f"Successfully Banned {member}", color=0x61187c)
embed.add_field(name="Reason:", value=f"{reason}", inline=True)
embed.set_footer(text="( ͡° ͜ʖ ͡°)")
await ctx.send(embed=embed)
await member.ban(reason=reason)
@_ban.error
async def ban_error(error, ctx):
if isinstance(error, MissingPermissions):
channel = message.channel
text = "Sorry {}, you do not have permissions to do that!".format(ctx.message.author)
await channel.send(text)

我很确定这是因为我的原因,但我不确定。

discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: ban_error() takes 2 positional arguments but 3 were given

这个错误不言自明。

您应该尝试实现async def ban_error的3个参数(您不必全部使用它们,只需确保其中有3个,因为库提供了3个参数

最新更新