I've been trying to make my bot's embed color update dynamically (using random color, editing HSV value). However, using msg.embeds[0]
seems to give me the previous shown embed.
Here's a snippet of my code:
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] });
});
I'm using the color-convert
library and this script (minus the substr()
) to edit the colors. I'm still new-ish to bots, so I might've missed something. How can I fix/improve it? I'll gladly share more info if needed.