0

I am creating a music bot for Discord and I seem to have stumbled in to a problem with the music queue. Whenever I want to see the queue, the songs are presented with a - before the name. I wish for the songs to be automatically numbered.

I have looked everywhere, including videos on youtube and tutorials. I still have no idea how to do it.

const serverQueue = message.client.queue.get(message.guild.id);
if (!serverQueue) 
  return message.channel.send(embed1);

const embedq = new Discord.RichEmbed()
  .setTitle(`**Now playing:** ${serverQueue.songs[0].title}`)
  .setDescription(`${serverQueue.songs.map(song => `${song.title}`).join('\n')}`)

I expect the output of the queue to look like this:

1) Joyner Lucas ft. Logic - ISIS
2) KSHMR x KAAZE - Devil Inside Me

However the actual output is

- Joyner Lucas ft. Logic - ISIS
1
  • Is (song, i) => `${i+1}) ${song.title}` instead of song => `${song.title}` what you want? Commented Aug 13, 2019 at 9:51

1 Answer 1

1

You can use the index of your .map iteration to add the numbers.

.setDescription(`
    ${serverQueue.songs.map((song, index) => `${index+1}) ${song.title}`).join('\n')}
`)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.