From df88729c44135ff9fdf5b3eb79ee1d3e09ff1b02 Mon Sep 17 00:00:00 2001 From: Souji Date: Fri, 28 Feb 2020 17:58:52 +0100 Subject: [PATCH] feat(MessageEmbed): re-introduce MessageEmbed#addField (#3850) * feat(MessageEmbed): re-introduce MessageEmbed#addField * suggestion: sorting alphabetically * suggestion: document inline to default false for #addField --- src/structures/MessageEmbed.js | 13 ++++++++++++- typings/index.d.ts | 1 + 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/structures/MessageEmbed.js b/src/structures/MessageEmbed.js index cad60d756..42750c42e 100644 --- a/src/structures/MessageEmbed.js +++ b/src/structures/MessageEmbed.js @@ -215,6 +215,17 @@ class MessageEmbed { (this.footer ? this.footer.text.length : 0)); } + /** + * Adds a field to the embed (max 25). + * @param {StringResolvable} name The name of this field + * @param {StringResolvable} value The value of this field + * @param {boolean} [inline=false] If this field will be displayed inline + * @returns {MessageEmbed} + */ + addField(name, value, inline) { + return this.addFields({ name, value, inline }); + } + /** * Adds fields to the embed (max 25). * @param {...EmbedFieldData|EmbedFieldData[]} fields The fields to add @@ -391,7 +402,7 @@ class MessageEmbed { * @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 + * @property {boolean} [inline=false] If this field will be displayed inline */ /** diff --git a/typings/index.d.ts b/typings/index.d.ts index 97bfb0520..55dc94eba 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -1053,6 +1053,7 @@ declare module 'discord.js' { public type: string; public url?: string; public readonly video: MessageEmbedVideo | null; + public addField(name: StringResolvable, value: StringResolvable, inline?: boolean): this; public addFields(...fields: EmbedFieldData[] | EmbedFieldData[][]): this; public attachFiles(file: (MessageAttachment | FileOptions | string)[]): this; public setAuthor(name: StringResolvable, iconURL?: string, url?: string): this;