discord.js presence status offline problem [duplicate]

夙愿已清 提交于 2021-01-29 15:01:08

问题


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

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