Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

Recently made a queue command for my bot and it works, but I'm wanting it to display in a RichEmbed.

let resp = `**Now Playing:**
${nowPlaying.songTitle}
**Requested By:**
${nowPlaying.requester}

**Queue**
`


for (var i = 1; i < queue.length; i++) {
    resp += `${i}. **${queue[i].songTitle}**
**Requested By:** ${queue[i].requester}
`
}

This is the current code I have set to display the queue. Now, my exact problem is resp +=. I know that each time a song is added to the queue and the command is rerun, it will have it listed as it is in the queue, but I'm still teaching myself Node.JS, so this is a little more difficult to solve, as I've never had any commands that use += to send an updated message.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
474 views
Welcome To Ask or Share your Answers For Others

1 Answer

Try something like this:

let q = ``;
for(var i = 0; i < queue.length; i++) {
    q += `
${i + 1}. **${queue[i].songTitle}**
Requested By: ${queue[i].requester}`;
}
let resp = [
    {name: `Now Playing`, value: nowPlaying.songTitle},
    {name: `Requested By`, value: nowPlaying.requester},
    {name: `Queue`, value: q},
];

//Putting it all together
message.channel.send({embed: {
    title: 'Queue',
    fields: resp,
}});

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...