异步def on_消息(消息,ctx)

2024-10-04 03:25:41 发布

您现在位置:Python中文网/ 问答频道 /正文

我的discord服务器上有一个名为#pay respecc的频道。这里的目标是让人们在不让麻烦制造者滥用系统的情况下支付他们的赔偿。我试着这样做,如果你在频道中发送了一些不是“f”的东西,它会被删除,机器人会给你一个警告。虽然它似乎不起作用。有什么想法吗?错误是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)

Tags: andtheclientmessageonchannelembedcontent