我有这个用于 discord.py 重写的 Python 代码:
@bot.command(pass_context=True)
async def clean(ctx):
if ctx.author.guild_permissions.administrator:
llimit = ctx.message.content[10:].strip()
await ctx.channel.purge(limit=llimit)
await ctx.send('Cleared by <@{.author.id}>'.format(ctx))
await ctx.message.delete()
else:
await ctx.send("You cant do that!")
但每次我收到这个错误:
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: '<=' not supported between instances of 'str' and 'int'
这里有人可以帮助我吗?
原文由 Shiba Luck 发布,翻译遵循 CC BY-SA 4.0 许可协议
为了声明参数,您可以将单个参数可调用对象(如
int
)视为 转换器。我还将您的权限检查更改为由commands.check
自动处理