refactor: use arrays instead of rest parameters for builders (#7759)

This commit is contained in:
Suneet Tipirneni
2022-04-21 12:56:10 -04:00
committed by GitHub
parent f22245e9d0
commit 29293d7bbb
11 changed files with 66 additions and 69 deletions

View File

@@ -17,12 +17,12 @@ import { EmbedAuthorOptions, EmbedFooterOptions, RGBTuple, UnsafeEmbedBuilder }
* Represents a validated embed in a message (image/video preview, rich embed, etc.)
*/
export class EmbedBuilder extends UnsafeEmbedBuilder {
public override addFields(...fields: APIEmbedField[]): this {
public override addFields(fields: APIEmbedField[]): this {
// Ensure adding these fields won't exceed the 25 field limit
validateFieldLength(fields.length, this.data.fields);
// Data assertions
return super.addFields(...embedFieldsArrayPredicate.parse(fields));
return super.addFields(embedFieldsArrayPredicate.parse(fields));
}
public override spliceFields(index: number, deleteCount: number, ...fields: APIEmbedField[]): this {

View File

@@ -44,7 +44,7 @@ export class UnsafeEmbedBuilder {
*
* @param fields The fields to add
*/
public addFields(...fields: APIEmbedField[]): this {
public addFields(fields: APIEmbedField[]): this {
if (this.data.fields) this.data.fields.push(...fields);
else this.data.fields = fields;
return this;
@@ -67,7 +67,7 @@ export class UnsafeEmbedBuilder {
* Sets the embed's fields (max 25).
* @param fields The fields to set
*/
public setFields(...fields: APIEmbedField[]) {
public setFields(fields: APIEmbedField[]) {
this.spliceFields(0, this.data.fields?.length ?? 0, ...fields);
return this;
}