Simplifying embed usage
Hi, I'm wondering if there is a way to not repeat the full embed builder every time I need an embed ? I already thought about a function in another class but I dont know how it should looks like
9 Replies
- 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 OPoh great do you have an example code using it ?
EmbedBuilder.from(theOtherEmbedHere)
Its going to depend on what your objective is though, if you want to like "recycle" other embeds then that works, but you could give more insight to what you need
I need to have a common template with color, title, thumbnail,footer...
I just want to edit the text without having 10-20 lines dedicated to an embed
yea you can create a template on a separate file, export that embed and then just set the properties you want to change
and if I only need to replace a value in description or in a field ?
I mean I just want to replace a word in a sentence already wrote in json
But idk how
String.prototype.replace()
The replace() method of String values returns a new string with one, some, or all matches of a pattern replaced by a replacement. The pattern can be a string or a RegExp, and the replacement can be a string or a function called for each match. If pattern is a string, only the first occurrence will be replaced. The original string is left unchanged.
Tysm ShompiFlen & Qjuh <:PES3_HoldHeart:760839325033693224>