'Context' 和 'int' 实例之间不支持 discord '>'

discord '>' not supported between instances of 'Context' and 'int'

当我尝试 运行 命令时,我总是收到此错误消息:“TypeError:‘>’在 'Context' 和 '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))```

正如我在评论中所说,您在命令中缺少 self

@commands.command()
async def clear(self, ctx, amount=5, max=100, min=1):
   ...

你应该像其他答案所说的那样传递一个“自我”参数。 但我也建议你在函数的代码块中定义最小和最大变量,而不是在函数的参数中。 因为人们可以将最小值更改为另一个值。在这种情况下,参数将是一个字符串。您没有将它们转换为整数,因此会出错。 永远不要相信你的用户 (;