Skip to content

Commit be35db2

Browse files
nyapatJiraliteArjunShardaalmeidx
authored
refactor(embed): deprecate addField (#8318)
Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com> Co-authored-by: Arjun Sharda <77706434+ArjunSharda@users.noreply.github.com> Co-authored-by: Almeida <almeidx@pm.me>
1 parent e95caa7 commit be35db2

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/structures/MessageEmbed.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const Util = require('../util/Util');
66

77
let deprecationEmittedForSetAuthor = false;
88
let deprecationEmittedForSetFooter = false;
9+
let deprecationEmittedForAddField = false;
910

1011
// TODO: Remove the deprecated code for `setAuthor()` and `setFooter()`.
1112

@@ -314,8 +315,18 @@ class MessageEmbed {
314315
* @param {string} value The value of this field
315316
* @param {boolean} [inline=false] If this field will be displayed inline
316317
* @returns {MessageEmbed}
318+
* @deprecated This method is a wrapper for {@link MessageEmbed#addFields}. Use that instead.
317319
*/
318320
addField(name, value, inline) {
321+
if (!deprecationEmittedForAddField) {
322+
process.emitWarning(
323+
// eslint-disable-next-line max-len
324+
'MessageEmbed#addField is deprecated and will be removed in the next major update. Use MessageEmbed#addFields instead.',
325+
'DeprecationWarning',
326+
);
327+
328+
deprecationEmittedForAddField = true;
329+
}
319330
return this.addFields({ name, value, inline });
320331
}
321332

typings/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1765,6 +1765,7 @@ export class MessageEmbed {
17651765
public type: string;
17661766
public url: string | null;
17671767
public readonly video: MessageEmbedVideo | null;
1768+
/** @deprecated This method is a wrapper for {@link MessageEmbed#addFields}. Use that instead. */
17681769
public addField(name: string, value: string, inline?: boolean): this;
17691770
public addFields(...fields: EmbedFieldData[] | EmbedFieldData[][]): this;
17701771
public setFields(...fields: EmbedFieldData[] | EmbedFieldData[][]): this;

0 commit comments

Comments
 (0)