Discord.py on_message() 缺少 @client.event 的参数

时间:2020-12-21 10:56:37

标签: python python-3.x arguments discord discord.py

async def on_message(ctx,x,op,y):
    if ctx.content.startswith("?!solve"):
         if op == "+":
        embed = discord.Embed(
            title=("Solved!"),
            description=("Problem: " + str(x + " + " + y + " \n\n") + "Answer: " + str(int(x) + int(y))),
            colour=discord.Colour.green()
        )
        elif op == "-":
            embed = discord.Embed(
                title=("Solved!"),
                description=("Problem: " + str(x + " - " + y + " \n\n") + "Answer: " + str(int(x) -      int(y))),
            colour=discord.Colour.green()
        )
        elif op == "x" or "×":
            embed = discord.Embed(
                title=("Solved!"),
                description=("Problem: " + str(x + " x " + y + " \n\n") + "Answer: " + str(int(x) * int(y))),
                colour=discord.Colour.green()
        )
        elif op == "/":
            embed = discord.Embed(
               title=("Solved!"),
                description=("Problem: " + str(x + " / " + y + " \n\n") + "Answer: " + str(int(x) / int(y))),
                colour=discord.Colour.green()
        )
        else:
            await ctx.send("Wrong Argument")

    await ctx.channel.send(embed=embed)

它一直说 x,op,y 缺少参数,我使用 @client.event 因为flask 忽略@client.commands()...也许你想知道为什么我需要flask,我使用flask 进行24/7 机器人托管所以...请帮帮我

1 个答案:

答案 0 :(得分:0)

这是一个事件,你只传递ONE参数,message,如果你想要所有其他的你需要使用命令

@client.event
async def on_message(message): # Only this argument
    ...
    await client.process_commands(message)


@client.command()
async def foo(ctx, x, op, y):
    ...