0

I am using quick.db for a Leaderboard command. It can show clearly the statistics ( you can see from the image that there are someone with 5 wins, etc). However, it cannot show the correct name-tag of that user. It is undefined.

const resp = await db.startsWith("money", { sort: ".data" });
resp.length = 10;
let finalOutput = " ";
for (var i in resp) {
finalOutput += `**${message.guild.members.cache.get(resp[i].ID.split("_")[1]).tag}** ~-~ ${resp[i].data} wins \n`;
  }

  const embed = new Discord.MessageEmbed()
    .setDescription(`${finalOutput}`)
    .setColor("#ffffff")

  message.channel.send(embed);

The above is my code. Is the message.guild.members.cache.get part wrong? If yes, what shall it be? Thank you very much.

Yet, this is the result. The user tags are "undefined".

zzz
  • 71
  • 1
  • 1
  • 6

1 Answers1

0

I have found the correct code.

message.guild.members.cache.get

should become:

bot.users.cache.get

Akj
  • 7,038
  • 3
  • 28
  • 40
zzz
  • 71
  • 1
  • 1
  • 6