More concise way to edit sent embeds

I am currently dealing editing the fields of an existing embed as a reply, where I'm only changing the fields and not the base content. However, so far the only way I've seen to edit embeds is to redefine the entire embed. I tried making a baseEmbed which only containts setTitle(), .setDescription etc, and using .addFields() for the editable content. However, .addFields() mutates the existing embed rather than making a new one and as such it simply keeps adding new copies of the fields. Is there any way to get this to work without having to repeat the .setTitle() etc.?
5 Replies
d.js toolkit
d.js toolkit17mo 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!
It's Manny
It's Manny17mo ago
I may be wrong but I believe EmbedBuilder accepts an APIembed as a constructor Unless I'm misunderstanding your question
d.js docs
d.js docs17mo ago
Structures from the API cannot be edited directly. To do so, you can create a new structure (a builder) using the .from() method
const newEmbed = EmbedBuilder.from(embed).setTitle("title")
const newRow = ActionRowBuilder.from(row).addComponents(component)
const newEmbed = EmbedBuilder.from(embed).setTitle("title")
const newRow = ActionRowBuilder.from(row).addComponents(component)
duck
duck17mo ago
as a side note, <EmbedBuilder>.setFields() exists and completely overwrites all fields
Val
ValOP17mo ago
that's really useful, thank you
Want results from more Discord servers?
Add your server