Discord.js 获取当前消息嵌入
Discord.js get current message embed
我一直在尝试让我的机器人的嵌入颜色动态更新(使用随机颜色,编辑 HSV 值)。但是,使用 msg.embeds[0]
似乎给我嵌入了 previous。
这是我的代码片段:
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()
)来编辑颜色。我对机器人还是新手,所以我可能错过了一些东西。我怎样才能fix/improve呢?如果需要,我很乐意分享更多信息。
我修复了它,必须在交互过程中将 msg =
放在 msg.edit()
前面以使其保持最新。
await i.deferUpdate();
await wait(0);
msg = await msg.edit({ embeds: [newEmbed], components: [row] });
我一直在尝试让我的机器人的嵌入颜色动态更新(使用随机颜色,编辑 HSV 值)。但是,使用 msg.embeds[0]
似乎给我嵌入了 previous。
这是我的代码片段:
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()
)来编辑颜色。我对机器人还是新手,所以我可能错过了一些东西。我怎样才能fix/improve呢?如果需要,我很乐意分享更多信息。
我修复了它,必须在交互过程中将 msg =
放在 msg.edit()
前面以使其保持最新。
await i.deferUpdate();
await wait(0);
msg = await msg.edit({ embeds: [newEmbed], components: [row] });