feat: bring embed builder field manipulation in line with underlying array functionality (#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
This commit is contained in:
Souji
2020-02-23 20:41:48 +01:00
committed by GitHub
parent ecd8cccddf
commit b727f6c1b9
6 changed files with 25 additions and 33 deletions

8
typings/index.d.ts vendored
View File

@@ -1070,8 +1070,7 @@ declare module 'discord.js' {
public type: string;
public url: string;
public readonly video: { url?: string; proxyURL?: string; height?: number; width?: number } | null;
public addBlankField(inline?: boolean): this;
public addField(name: StringResolvable, value: StringResolvable, inline?: boolean): this;
public addFields(...fields: EmbedField[] | EmbedField[][]): this;
public attachFiles(file: (MessageAttachment | FileOptions | string)[]): this;
public setAuthor(name: StringResolvable, iconURL?: string, url?: string): this;
public setColor(color: ColorResolvable): this;
@@ -1082,10 +1081,11 @@ declare module 'discord.js' {
public setTimestamp(timestamp?: Date | number): this;
public setTitle(title: StringResolvable): this;
public setURL(url: string): this;
public spliceField(index: number, deleteCount: number, name?: StringResolvable, value?: StringResolvable, inline?: boolean): this;
public spliceFields(index: number, deleteCount: number, ...fields: EmbedField[] | EmbedField[][]): this;
public toJSON(): object;
public static checkField(name: StringResolvable, value: StringResolvable, inline?: boolean): Required<EmbedField>;
public static normalizeField(name: StringResolvable, value: StringResolvable, inline?: boolean): Required<EmbedField>;
public static normalizeFields(...fields: EmbedField[] | EmbedField[][]): Required<EmbedField>[];
}
export class MessageMentions {