Python discord.py(清除命令)中有错误

Python discord.py(清除命令)中有错误,python,python-3.x,discord.py,Python,Python 3.x,Discord.py,我有以下用于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)

我有以下用于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!")
@bot.command(pass\u context=True)
异步def清洁(ctx):
如果ctx.author.guild\u permissions.administrator:
llimit=ctx.message.content[10:].strip()
等待ctx.channel.purge(限制=llimit)
等待ctx.send('已清除'。格式(ctx))
等待ctx.message.delete()
其他:
等待ctx.send(“你不能那样做!”)
但每次我遇到这个错误:

discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: '<=' not supported between instances of 'str' and 'int'

discord.ext.commands.errors.CommandInvokeError:Command引发异常:TypeError:“函数的
limit
参数将整数作为值

试着做这样的事情

@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=int(llimit))
            await ctx.send('Cleared by <@{.author.id}>'.format(ctx))
        await ctx.message.delete()
else:
    await ctx.send("You cant do that!")
@bot.command(pass\u context=True)
异步def清洁(ctx):
如果ctx.author.guild\u permissions.administrator:
llimit=ctx.message.content[10:].strip()
等待ctx.channel.purge(限制=int(llimit))
等待ctx.send('已清除'。格式(ctx))
等待ctx.message.delete()
其他:
等待ctx.send(“你不能那样做!”)

我不完全确定你想用
内容[10:].strip()
完成什么,但是如果你试图忽略
!清除
命令的一部分,您使用的数字太大
content[7://code>就足够了

您可以将单参数可调用项(如
int
)视为声明参数的目的。我还将您的权限检查更改为由


llimit
是一个字符串,你需要一个int。
int(llimit)
@abccd你能把带int的代码发给我吗?我的前缀是shb!,唯一错误的是我忘记了整数。。。谢谢兄弟,请为任何英语错误道歉
@bot.command(pass_context=True)
@commands.has_permissions(administrator=True)
async def clean(ctx, limit: int):
        await ctx.channel.purge(limit=limit)
        await ctx.send('Cleared by {}'.format(ctx.author.mention))
        await ctx.message.delete()

@clean.error
async def clear_error(ctx, error):
    if isinstance(error, commands.MissingPermissions):
        await ctx.send("You cant do that!")