Edit Embed with buttons

Hey, I have an embed and btns, I can also access the btns, but now I want the embed to be edited when I click on the previous btn, for example, it doesn't matter at first, the main thing is that something happens. If I do interaction.update... it works. But I just can't figure out how to edit the embed. To keep it simple, I'm sending a git repo: https://github.com/TheBrain08/DCBot The files in question are: src/utils/handleButtonInteractions.js src/events/interactionCreate/handleCommands.js src/commands/moderation/help.js Thanks in advance [email protected] node: v22.11.0
GitHub
GitHub - TheBrain08/DCBot
Contribute to TheBrain08/DCBot development by creating an account on GitHub.
5 Replies
d.js toolkit
d.js toolkit3mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by OP
Mark
Mark3mo ago
You can do EmbedBuilder.from(oldEmbed) and then use that returned builder to change what you want and pass it to update()
TheBrain04
TheBrain04OP3mo ago
okay but how can i acces the oldEmbed ? like this:
interaction.message.embeds[0]
interaction.message.embeds[0]
?
Mark
Mark3mo ago
did you try it?
TheBrain04
TheBrain04OP3mo ago
i tried this
console.log(interaction.message.embeds[0].title);
const newEmbed = EmbedBuilder.from(interaction.message.embeds[0]).setTitle(
"updated"
);
await interaction.update({ embeds: [newEmbed] });
console.log(interaction.message.embeds[0].title);
console.log(interaction.message.embeds[0].title);
const newEmbed = EmbedBuilder.from(interaction.message.embeds[0]).setTitle(
"updated"
);
await interaction.update({ embeds: [newEmbed] });
console.log(interaction.message.embeds[0].title);
and thas the error....
throw new DiscordAPIError(data, "code" in data ? data.code : data.error, status, method, url, requestData);
^

DiscordAPIError[40060]: Interaction has already been acknowledged.
throw new DiscordAPIError(data, "code" in data ? data.code : data.error, status, method, url, requestData);
^

DiscordAPIError[40060]: Interaction has already been acknowledged.
the first console.log() is still executed and then it crashes nvm my bad i have it. But thank you for the tip with the EmbedBuilder.from !

Did you find this page helpful?