Discord.js: Discord.RichEmbed should have a .clearFields()

Created on 2 Apr 2019  路  7Comments  路  Source: discordjs/discord.js

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when I want to re-use Rich Embeds but have to construct a whole new object to clear the fields.

Describe the ideal solution
RichEmbed should have a .clearFields() so you can easily re-use RichEmbed objects.

Describe alternatives you've considered
I could make a seperate function to remake my object but I have a lot of requirements and thus, its easier to not.

Additional context
.clearFields would be easy to add. I want do a message.channel.send(richEmbed)
then change some attributes but I wan't to clear the fields to send it again.

utility enhancement

Most helpful comment

The <RichEmbed>.fields property is just an array, you can clear the fields using <RichEmbed>.fields = []

All 7 comments

The <RichEmbed>.fields property is just an array, you can clear the fields using <RichEmbed>.fields = []

you don't need to worry about creating lots of embed objects

Is this something desired in the library i can work on this if we need and send a PR for it. Something to note:
embed.spliceField(0, 25) might already do what this needs.

embed.fields is already an array, you can just do embed.fields.slice()

spliceFields() exists on master already, which is what Skillz was referencing.
Otherwise yes, you're right and you can use Array methods on the array directly or reset it as I showed... almost three months ago.

This issue should probably just be closed, unless someone really wants this method to exist.

I think that for most people, they don't know that fields are an array and, for them, the clearFields() function should exist. If the RichEmbed() class is made to easily build an embed using methods why not add this one? At that point ask them to push into the array embeds.fields and remove the addField() method? In my opinion, the more the RichEmbed() class will include a method to facilitate the use of the embeds, the better. After that, it remains my opinion as not api creator ^^

I think that for most people, they don't know that fields are an array

They should read the docs.

Builders don't really need methods to "un-build" themselves.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Dmitry221060 picture Dmitry221060  路  3Comments

Acaretia picture Acaretia  路  3Comments

Alipoodle picture Alipoodle  路  3Comments

ghost picture ghost  路  3Comments

kvn1351 picture kvn1351  路  3Comments