From a3f8f9f0fa27086326a74b3deec6f83b30d8cb8e Mon Sep 17 00:00:00 2001 From: March 7th <71698422+aiko-chan-ai@users.noreply.github.com> Date: Tue, 26 Jul 2022 09:57:57 +0700 Subject: [PATCH] refactor(embed): deprecate addField #8318 v13.9.1 --- 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 02367fd..ae2c847 100644 --- a/src/structures/MessageEmbed.js +++ b/src/structures/MessageEmbed.js @@ -6,8 +6,9 @@ const Util = require('../util/Util'); let deprecationEmittedForSetAuthor = false; let deprecationEmittedForSetFooter = false; +let deprecationEmittedForAddField = false; -// TODO: Remove the deprecated code for `setAuthor()` and `setFooter()`. +// TODO: Remove the deprecated code for `setAuthor()`, `setFooter()` and `addField()`. /** * Represents an embed in a message (image/video preview, rich embed, etc.) @@ -314,8 +315,18 @@ class MessageEmbed { * @param {string} value The value of this field * @param {boolean} [inline=false] If this field will be displayed inline * @returns {MessageEmbed} + * @deprecated This method is a wrapper for {@link MessageEmbed#addFields}. Use that instead. */ addField(name, value, inline) { + if (!deprecationEmittedForAddField) { + process.emitWarning( + // eslint-disable-next-line max-len + 'MessageEmbed#addField is deprecated and will be removed in the next major update. Use MessageEmbed#addFields instead.', + 'DeprecationWarning', + ); + + deprecationEmittedForAddField = true; + } return this.addFields({ name, value, inline }); } diff --git a/typings/index.d.ts b/typings/index.d.ts index d2cc4bb..ae5edcd 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -2035,6 +2035,7 @@ export class MessageEmbed { public type: string; public url: string | null; public readonly video: MessageEmbedVideo | null; + /** @deprecated This method is a wrapper for {@link MessageEmbed#addFields}. Use that instead. */ public addField(name: string, value: string, inline?: boolean): this; public addFields(...fields: EmbedFieldData[] | EmbedFieldData[][]): this; public setFields(...fields: EmbedFieldData[] | EmbedFieldData[][]): this;