Discord.py throws error: to many arguments on purge()
Discord.py throws error: to many arguments on purge()
Hi there, the following code is supposed to clear the channel. If the
argument is a nomber, it is supposed to delete as many messages as
specified. If the argument is all, it is supposed to delete all
messages, and if you don't specifie an argument, it should delete 10
messages as default.
@client.command()
@commands.has_permissions(manage_messages=True)
async def clear(ctx, amount=None):
try:
await ctx.channel.purge(limit=int(amount) + 1)
except:
if amount == 'all':
await ctx.channel.purge()
return
await ctx.channel.purge(10)
however, Im getting the following error, if i do !clear without an
argument:
命令引发异常:TypeError:purge() 采用 1 个位置参数,但给出了 2 个
error
purge
使用关键字参数,所以你必须写 limit=10
而不是 10
,请参阅 the documentation
Hi there, the following code is supposed to clear the channel. If the argument is a nomber, it is supposed to delete as many messages as specified. If the argument is all, it is supposed to delete all messages, and if you don't specifie an argument, it should delete 10 messages as default.
@client.command()
@commands.has_permissions(manage_messages=True)
async def clear(ctx, amount=None):
try:
await ctx.channel.purge(limit=int(amount) + 1)
except:
if amount == 'all':
await ctx.channel.purge()
return
await ctx.channel.purge(10)
however, Im getting the following error, if i do !clear without an argument:
命令引发异常:TypeError:purge() 采用 1 个位置参数,但给出了 2 个
error
purge
使用关键字参数,所以你必须写 limit=10
而不是 10
,请参阅 the documentation