删除频道中特定用户的所有消息 discord.py
Delete all message from a specific user in a channel discord.py
这是一行代码,用于删除discord中文本频道中的一定数量的消息
await ctx.channel.purge(limit=amount)
如果我使用 purge
功能,它将删除 每个人 发送的所有消息。但我只想删除来自特定用户的消息,例如mee6,而不是频道中所有人的所有消息。
我可以知道怎么做吗?谢谢
您可以使用 TextChannel.purge
的 check
参数:
user = user_to_delete
await ctx.channel.purge(limit=amount, check=lambda m: m.author == user)
这是一行代码,用于删除discord中文本频道中的一定数量的消息
await ctx.channel.purge(limit=amount)
如果我使用 purge
功能,它将删除 每个人 发送的所有消息。但我只想删除来自特定用户的消息,例如mee6,而不是频道中所有人的所有消息。
我可以知道怎么做吗?谢谢
您可以使用 TextChannel.purge
的 check
参数:
user = user_to_delete
await ctx.channel.purge(limit=amount, check=lambda m: m.author == user)