-1

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.

1 Answer 1

0

I fixed it, had to put msg = in front of msg.edit() during an interaction to keep it up to date.

await i.deferUpdate();
await wait(0);
msg = await msg.edit({ embeds: [newEmbed], components: [row] });
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.