【问题标题】:Discord.py find all messages from user and check content of each messageDiscord.py 查找来自用户的所有消息并检查每条消息的内容
【发布时间】:2020-12-17 03:09:26
【问题描述】:

我想知道 discord.py 中是否有任何方法可以检查用户发送的每条消息,并让机器人查找特定单词或单词列表的每次出现并返回出现次数。

【问题讨论】:

    标签: python discord.py


    【解决方案1】:

    实际上,使用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
    

    reference

    【讨论】:

      猜你喜欢
      • 2022-01-14
      • 1970-01-01
      • 2018-03-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-10-06
      • 2022-01-24
      • 1970-01-01
      相关资源
      最近更新 更多