Discord.js获取当前消息嵌入



我一直试图使我的机器人的嵌入颜色动态更新(使用随机颜色,编辑HSV值)。然而,使用msg.embeds[0]似乎给了我前面的显示嵌入。

下面是我的代码片段:

collector.on('end', () => {
currentEmbed = msg.embeds[0]
const rowAgain = msg.components[0]
for (c of rowAgain.components) {
c.disabled = true;
}
let colorHex = `#${vb2Hex(currentEmbed.color)}`;
const colorHsv = hex.hsv(colorHex);
const val = colorHsv[2] - 5;
colorHsv.splice(2, 1, val);
colorHex = hsv.hex(colorHsv);
color = parseInt(colorHex, 16);
currentEmbed.color = color;
msg.edit({ embeds: [currentEmbed], components: [row] });
});

我使用color-convert库和这个脚本(减去substr())来编辑颜色。我对机器人还是新手,所以我可能错过了什么。我该如何修复/改进它?如果需要,我很乐意分享更多的信息。

我修复了它,必须在交互期间将msg =放在msg.edit()前面以保持最新。

await i.deferUpdate();
await wait(0);
msg = await msg.edit({ embeds: [newEmbed], components: [row] });

最新更新