Discord.py 自动删除机器人命令

时间:2021-07-13 05:07:25

标签: python discord discord.py

如何使用机器人通过用户 ID 自动删除某人的消息?

2 个答案:

答案 0 :(得分:1)

有一个 on_message 事件:

@commands.Cog.listener()
async def on_message(self, message):
    if message.author.id == some_id:
        await message.delete()

答案 1 :(得分:0)

如果您使用的是 discord.ext,那就是解决方案:

@bot.event()
async def on_message(ctx):
    if message.author.id == 982628765833: #Replace the id with the person's id that you want to delete their message
        await ctx.delete()