Leaderboard Command Acting Weird
Closed this issue · 2 comments
So... I created a leaderboard command in my code, and it works fine. Problem is that it only correctly identifies me in the server leaderboard, and several other users in my server have xp but are notated as "Unknown#0000" in the leaderboard. I copied the code for the leaderboard command from the discord-xp npm site word for word, but it's giving me this issue. Is there some way to fix this?
Feel free to contact me via Discord at DarkMageXOfficial#4355
Thanks,
DarkMageX
reason is beacuse of the intents:
Maintaining a stateful application can be difficult when it comes to the amount of data you're expected to process, especially at scale. Gateway Intents are a system to help you lower that computational burden.
Some intents are defined as "Privileged" due to the sensitive nature of the data. Those intents are:
GUILD_PRESENCES
GUILD_MEMBERS
Once your bot reaches 100 or more servers, Privileged Intents require Verification and whitelisting.
My bot uses those intents! How do I fix this?
First you need to go to your bot page on the discord developer portal and click on 'bot', below your token enable these two features https://i.imgur.com/WfBLtXY.png.
once you have done that now you have to implement the intents into your bot! you can do this by simply going to your index.js file and where you defined client/bot add the partials like this:
new Discord.Client({ ws: { intents: ['GUILDS', 'GUILD_MESSAGES', 'GUILD_MEMBERS', 'GUILD_PRESENCES'] } });
now you just have to commit and you are done!
You either enable GUILD_MEMBERS
intent, or use latest version v1.1.7
and pass the fetchUsers
argument as third argument to computeLeaderboard
function (but its slower & does not require gateway intents). Please do note that this new version contains braking changes to the existing code, check latest changelog and examples for more information on how to update.