I've tried making a leaderboard command with quick.db for my Discord.js bot but it isnt working. It replies with undefined users and stuff like that!
var money = await db.all(`money_${message.guild.id}`, { sort: ".data" });
let resp = "";
for (let i = 0; i < money.length; i++) {
let user = client.users.cache.get(money[i].ID.split("_")[1]);
resp += `${i + 1}. ${user} - ${money[i].data}$\n`;
}
return message.channel.send(
new Discord.MessageEmbed().setAuthor(`Leaderboard`).setDescription(resp)
);
Here is the code ^^^^
Here is the output for the command
It means that
money[i].ID.split("_")[1]
is not a valid ID. Have you thought about logging these values in the loop to check the validity of the data you store?