【发布时间】:2021-03-28 13:39:04
【问题描述】:
当我尝试运行命令时,我总是收到以下错误消息:“TypeError: '>' not supported between 'Context' and 'int'”
from discord.ext import commands
class clear(commands.Cog):
def __init__(self, client):
self.client = client
# Events
@commands.Cog.listener()
async def on_ready(self):
print('Clear modul started')
# Command
@commands.command()
async def clear(ctx, amount=5, max=100, min=1):
if (amount > max):
await ctx.send(f"The value is too high! Enter a value `{min}-{max}` between.", delete_after=5)
elif (amount < min):
await ctx.send(f"The value is too small! Enter a value `{min}-{max}` between.", delete_after=5)
else:
await ctx.channel.purge(limit=amount+1)
await ctx.send(f"Törölve {amount}", delete_after=5)
def setup(client):
client.add_cog(clear(client))```
【问题讨论】:
-
导致此错误的调用是什么?我可以看到发生的情况是您传递了一个“上下文”对象作为数量。
-
你缺少自我
-
我不知道。该命令在 main.py 中有效,但是当我将其传输到单独的文件时,我得到了这个。
标签: python if-statement discord integer discord.py