【发布时间】:2018-09-27 21:52:26
【问题描述】:
我有这个用于 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'
有人可以帮帮我吗?
【问题讨论】:
-
llimit是一个字符串,你需要一个 int。int(llimit) -
@abccd 你能把带int的代码发给我吗?
标签: python python-3.x discord.py