将队列列表变成嵌入 [英] Turn queue list into an embed

查看:69
本文介绍了将队列列表变成嵌入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近为我的机器人发出了一个队列命令,它可以工作,但是我希望它显示在RichEmbed中。

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:**\n${nowPlaying.songTitle}\n**Requested By:**\n${nowPlaying.requester}\n\n**Queue**\n`


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

这是我设置为显示队列的当前代码。现在,我的确切问题是 resp + = 。我知道每次将歌曲添加到队列中并重新运行命令时,它都会按队列中的顺序列出它,但是我仍然在自学Node.JS,因此解决起来有点困难,因为我从来没有任何命令使用 + = 发送更新的消息。

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.

推荐答案

尝试类似这样的事情:

let q = ``;
for(var i = 0; i < queue.length; i++) {
    q += `\n${i + 1}. **${queue[i].songTitle}**\nRequested 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,
}});

这篇关于将队列列表变成嵌入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆