Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/294.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何在discord.py中的'commands.Bucket'中获取费率限制人员_Python_Python 3.x_Discord.py - Fatal编程技术网

Python 如何在discord.py中的'commands.Bucket'中获取费率限制人员

Python 如何在discord.py中的'commands.Bucket'中获取费率限制人员,python,python-3.x,discord.py,Python,Python 3.x,Discord.py,所以我有一个反垃圾邮件系统,它是在on_messageevent of discord.py中创建的。相同的代码如下--> @bot.event 异步def on_消息(消息): 等待机器人。等待直到准备就绪() 如果message.author==bot.user: 返回 bucket=bot.AntiSpam.get\u bucket(消息) 重试\u after=bucket.update\u rate\u limit() 如果在以下时间后重试\u: 打印(‘有人在淘气’) 等待消息.ch

所以我有一个反垃圾邮件系统,它是在
on_message
event of discord.py中创建的。相同的代码如下-->

@bot.event
异步def on_消息(消息):
等待机器人。等待直到准备就绪()
如果message.author==bot.user:
返回
bucket=bot.AntiSpam.get\u bucket(消息)
重试\u after=bucket.update\u rate\u limit()
如果在以下时间后重试\u:
打印(‘有人在淘气’)
等待消息.channel.purge(before=datetime.utcnow(),before=datetime.utcnow()-timedelta(秒=5))
wait message.channel.send(f'Please't spam,{message.author.notice}',delete_after=5.0)

这将删除过去5秒钟以来发送的每一条消息。如何使它只删除该垃圾邮件发送者发送的邮件?我知道我必须使用
TextChannel.purge()
检查
kwarg,但我需要一种方法来进行检查。在这方面我能得到什么帮助吗?

检查将非常简单:

def检查(m):
返回m.author==message.author
等待消息.channel.purge(before=datetime.utcnow(),before=datetime.utcnow()-timedelta(秒=5),check=check)
我们正在检查传入检查的消息的作者是否与前一条消息的作者相同