Search code examples
javascriptdiscordembedleaderboard

how to change this embed?


Hiiii! So after many days im finally close to finishing my "currency bot". One of the last parts is the leaderboard, and it's working. but, I don't like how it looks but I don't know how to change it. It might sound confusing so I'm just gonna put some screenshots to make it clear

1]

This is the message I'm getting but I want the number to be in the same line as the user and number:

  1. @Pegasus BOT - 100000
  2. @wex - 11000
  3. @wextest - 2000

Here's part of the code I'm using:

const topembed = new Discord.MessageEmbed()
.setColor('#FF3A0E')
.setTitle(message.guild.name + "'s TOP Donators!")
.setTimestamp()

if(res.length === 0) {
    topembed.addField(`No data found`)
} else if(res.length < 10) {
    for(i = 0; i < res.length; i++) {
        let member = res[i].userID
            topembed.addField(`${i + 1}`, `${member} **- ${res[i].donos}**`,)

I use MongoDB to save data if it matters

Thanks for your help!


Solution

  • You can use \n to begin a new line. Maybe description might be more suitable.

    var description = ""
    for(i = 0; i < res.length; i++) {
      let member = res[i].userID
      description += `${i + 1}. ${member} **- ${res[i].donos}**\n`
    }
    topembed.setDescription(description)