-
-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: bring embed builder field manipulation in line with underlying array functionality #3761
Conversation
* remove MessageEmbed#spliceField * add MessageEmbed#spliceFields * to behave more like Array#splice * and allow multiple fields to be replaced/inserted * update typings accordingly
* check suggests boolean return type
a66f2f7
to
eb6c39e
Compare
eb6c39e
to
7930023
Compare
* for Array#flat
This looks great! Can you also bump the node version in the package.json engines field? |
Also, looking into it, can't a generator function be introduced to flatten arrays without having to bump to a different node version? |
This won't be necessary as we are probably going to target 12 anyway, latest LTS |
As Pyro pointed out on the server:
I'm personally in favor of 1, as from experience tempering with embed layout using blank fields never yields the desired result in the first place, even more so after the rather recent embed update in which discord restyled embeds. Edit: |
…array functionality (discordjs#3761) * feat: splice multiple fields * remove MessageEmbed#spliceField * add MessageEmbed#spliceFields * to behave more like Array#splice * and allow multiple fields to be replaced/inserted * update typings accordingly * refactor: rename check to normalize * check suggests boolean return type * feat: allow spread args or array as field input * rewrite: replace addField in favor of addFields * typings: account for changes * chore: bump min node to 11.0.0 * for Array#flat * fix: bump min-node in package engines field * remove addBlankField
…erlying array functionality (discordjs#3761)" This reverts commit 70e0669.
Please describe the changes this PR makes and why it should be merged:
The applied approach brings the embed utility methods more in line with the underlying actions done on the raw field array (push, splice) while (hopefully) cleanly handling both rest parameters as well as array passing.
While it does remove some convenience, namely
.addField("foo", "bar")
we discussed that keeping both #addField and #addFields simultaneously should not be the way to go, adding more noise to the interface than necessary (see the earlier deprecation of #addFile in favor of #addFiles)Example
ℹ Both methods also support the fields to be provided as an Array
⚠Due to the use of Array#flat this will require a min node bump to 11
TODO:
Status
Semantic versioning classification: