【发布时间】:2020-12-17 03:09:26
【问题描述】:
我想知道 discord.py 中是否有任何方法可以检查用户发送的每条消息,并让机器人查找特定单词或单词列表的每次出现并返回出现次数。
【问题讨论】:
标签: python discord.py
我想知道 discord.py 中是否有任何方法可以检查用户发送的每条消息,并让机器人查找特定单词或单词列表的每次出现并返回出现次数。
【问题讨论】:
标签: python discord.py
实际上,使用channel.history 方法,传递一个检查函数来检查消息是否是用户发送的,这里是一个例子
def check(message):
return message.author.id == some_author_id
messages = await channel.history(limit=100, check=check).flatten()
# Now you have 100 messages sent by a user
# You can now iterate through every message and check whatever you want
【讨论】: