Using discord.py, how would i check how much messages a user has sent in a specific channel

有些话、适合烂在心里 提交于 2021-01-29 07:52:41

问题


Using discord.py, how would i check how much messages a user has sent in a specific channel, and then for example every week, the bot will send a message for how much messages a user has sent for example, if i sent 30 messages in "#test" in a week, when the week ends it will send "@User has sent: 30 messages in #test".

I'm not sure what to try.

All I have setup is my bot with:

@client.event
async def on_message(message):

no errors


回答1:


Look at the discord.py documentation.

You can use:

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

or something similar. More details are in the documentation.



来源:https://stackoverflow.com/questions/57540536/using-discord-py-how-would-i-check-how-much-messages-a-user-has-sent-in-a-speci

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!