【问题标题】:Using discord.py, how would i check how much messages a user has sent in a specific channel使用 discord.py,我将如何检查用户在特定频道中发送了多少消息
【发布时间】:2019-12-23 17:12:21
【问题描述】:

使用 discord.py,我将如何检查用户在特定频道中发送了多少消息,然后例如每周,机器人将发送一条消息,说明用户发送了多少消息 例如,如果我一周内在“#test”中发送了 30 条消息,那么当一周结束时,它将发送“@User has sent: 30 messages in #test”。

我不确定要尝试什么。

我所设置的只是我的机器人:

@client.event
async def on_message(message):

没有错误

【问题讨论】:

    标签: python discord.py


    【解决方案1】:

    查看discord.py documentation

    你可以使用:

    counter = 0
    async for message in channel.history():
        if message.author == client.user:
            counter += 1
    

    或类似的东西。更多细节在文档中。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-09-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-03-18
      • 2019-12-28
      • 1970-01-01
      相关资源
      最近更新 更多