typings(MessageEmebd): fix typings for addFields (#3821)

* typings(MessageEmebd): fix typings for addFields

* fix: add missing semicolon

* docs(MessageEmbed): fix various types

* in accordance with the scope of the PR

* Update src/structures/MessageEmbed.js

Co-Authored-By: SpaceEEC <spaceeec@yahoo.com>

Co-authored-by: SpaceEEC <spaceeec@yahoo.com>
This commit is contained in:
Souji
2020-02-24 14:02:06 +01:00
committed by GitHub
parent 967b533e9d
commit 54f24d1fea
2 changed files with 20 additions and 7 deletions

View File

@@ -216,7 +216,7 @@ class MessageEmbed {
/**
* Adds a fields to the embed (max 25).
* @param {...EmbedField|EmbedField[]} fields The fields to add
* @param {...EmbedFieldData|EmbedFieldData[]} fields The fields to add
* @returns {MessageEmbed}
*/
addFields(...fields) {
@@ -228,7 +228,7 @@ class MessageEmbed {
* Removes, replaces, and inserts fields in the embed (max 25).
* @param {number} index The index to start at
* @param {number} deleteCount The number of fields to remove
* @param {...EmbedField|EmbedField[]} [fields] The replacing field objects
* @param {...EmbedFieldData|EmbedFieldData[]} [fields] The replacing field objects
* @returns {MessageEmbed}
*/
spliceFields(index, deleteCount, ...fields) {
@@ -386,9 +386,16 @@ class MessageEmbed {
return { name, value, inline };
}
/**
* @typedef {Object} EmbedFieldData
* @property {StringResolvable} name The name of this field
* @property {StringResolvable} value The value of this field
* @property {boolean} [inline] If this field will be displayed inline
*/
/**
* Check for valid field input and resolves strings
* @param {...EmbedField|EmbedField[]} fields Fields to normalize
* @param {...EmbedFieldData|EmbedFieldData[]} fields Fields to normalize
* @returns {EmbedField[]}
*/
static normalizeFields(...fields) {

14
typings/index.d.ts vendored
View File

@@ -1068,7 +1068,7 @@ declare module 'discord.js' {
public type: string;
public url?: string;
public readonly video: MessageEmbedVideo | null;
public addFields(...fields: EmbedField[] | EmbedField[][]): this;
public addFields(...fields: EmbedFieldData[] | EmbedFieldData[][]): this;
public attachFiles(file: (MessageAttachment | FileOptions | string)[]): this;
public setAuthor(name: StringResolvable, iconURL?: string, url?: string): this;
public setColor(color: ColorResolvable): this;
@@ -1079,11 +1079,11 @@ declare module 'discord.js' {
public setTimestamp(timestamp?: Date | number): this;
public setTitle(title: StringResolvable): this;
public setURL(url: string): this;
public spliceFields(index: number, deleteCount: number, ...fields: EmbedField[] | EmbedField[][]): this;
public spliceFields(index: number, deleteCount: number, ...fields: EmbedFieldData[] | EmbedFieldData[][]): this;
public toJSON(): object;
public static normalizeField(name: StringResolvable, value: StringResolvable, inline?: boolean): Required<EmbedField>;
public static normalizeFields(...fields: EmbedField[] | EmbedField[][]): Required<EmbedField>[];
public static normalizeField(name: StringResolvable, value: StringResolvable, inline?: boolean): Required<EmbedFieldData>;
public static normalizeFields(...fields: EmbedFieldData[] | EmbedFieldData[][]): Required<EmbedFieldData>[];
}
export class MessageMentions {
@@ -2184,6 +2184,12 @@ declare module 'discord.js' {
interface EmbedField {
name: string;
value: string;
inline: boolean;
}
interface EmbedFieldData {
name: StringResolvable;
value: StringResolvable;
inline?: boolean;
}