问题
client.on('message', message => {
let onlineCount = 0;
const guild = client.guilds.cache.get("538745138047090708");
guild.members.cache.find(member => {
if (member.presence.status == "online"){
onlineCount += 1
}
})
message.channel.send(`Online Players In Server: ${onlineCount}`)};
As you see in picture bot says online players in server is 0 but it's not. There is too many online on server but i don't know how to fix it
Click For Image
回答1:
Since my reputation is low I cannot comment on your question. As of 27th of October discord bots need to enable presence intent. You can find that under applications>BotName>Bot
If you cannot enable it with button, you need to contact discord support team. Here is the article
来源:https://stackoverflow.com/questions/64662794/discord-js-presence-status-offline-problem