简体   繁体   English

Discord.js 关于角色和消息计数的问题

[英]Discord.js question regarding roles and message counting

How can I get a list of all user IDs from a specific role for example "Twitch Follower", and have the bot count how many messages they sent in a specific channel?如何从特定角色(例如“Twitch Follower”)获取所有用户 ID 的列表,并让机器人计算他们在特定频道中发送的消息数量?

You can use MessageManager#fetch :您可以使用MessageManager#fetch

// <client> is a placeholder for the client object. This could commonly be `message.client`

<client>.channels.cache.get('<channel ID>').messages.fetch(_, true, true).then(messages => {
   console.log(messages.filter(m => m.member.roles.has('<role ID>')).size)
}

Keep in mind, the limit of messages you can fetch is 100请记住,您可以获取的消息限制为100

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM