异步def on_message(message,ctx)

时间:2020-05-24 17:20:02

标签: python discord discord.py

我的不和谐服务器上有一个名为#pay-respecc的频道。这里的目标是使人们能够支付自己的规格,而不会麻烦制造者滥用该系统。我尝试这样做,因此如果您在通道中发送的不是“ f”的东西,它将被删除,并且bot会向您发送警告。尽管它似乎不起作用。有任何想法吗?错误为TypeError: on_message() missing 1 required positional argument: 'ctx

@client.event
async def on_message(message, ctx):
    if message.content != "f" and message.channel.id == 699364974014890044:
        await message.delete()
        embed = discord.Embed(
            title = 'Paying respeccs',
            description = 'Please do not abuse your ability to pay respeccs. To pay respecc the correct way, please send `f`. Any other message will be deleted and reviewed by the staff team in the case of offendable messages.',
            color = discord.Color.from_rgb(r=159, g=255, b=255)
        )
        embed.set_footer(text='{}' .format(ctx.author))
        await ctx.author.send(embed=embed)
        print(f"Deleted '{message.content}' on channel #payrespecc by {message.author}. Warning message has been sent!")
    await client.process_commands(message)

1 个答案:

答案 0 :(得分:0)

on_message()不接收ctx,仅message。 参见https://discordpy.readthedocs.io/en/latest/quickstart.html