Leaderboards user returning as Unknown#0000
Closed this issue · 1 comments
This is the code im using
`const Discord = require('discord.js')
const client = new Discord.Client()
const Levels = require("discord-xp");
Levels.setURL("mongodb://ug8yoeq4nlrnbbcawthl:gAGzjsntMZz6uIHLeyy3@bbrs0e7qsv3xczd-mongodb.services.clever-cloud.com:27017/");
module.exports = {
name: 'leaderboard',
asliases: ['ss', 'SS'],
async execute(message, args) {
const rawLeaderboard = await Levels.fetchLeaderboard(message.guild.id, 10); // We grab top 10 users with most xp in the current server.
if (rawLeaderboard.length < 1) return reply("Nobody's in leaderboard yet.");
const leaderboard = Levels.computeLeaderboard(client, rawLeaderboard); // We process the leaderboard.
const lb = leaderboard.map(e => ${e.position}. ${e.username}#${e.discriminator}\nLevel: ${e.level}\nXP: ${e.xp.toLocaleString()}
); // We map the outputs.
message.channel.send(**Leaderboard**:\n\n${lb.join("\n\n")}
);
}
}`
Unknown is returned because user isnt cached within bot's memory.