Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(embed): deprecate addField #8318

Merged
merged 7 commits into from Jul 23, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/structures/MessageEmbed.js
Expand Up @@ -6,6 +6,7 @@ const Util = require('../util/Util');

let deprecationEmittedForSetAuthor = false;
let deprecationEmittedForSetFooter = false;
let deprecationEmittedForAddField = false;

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

Expand Down Expand Up @@ -314,8 +315,17 @@ 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(
'MessageEmbed#addField is deprecated and removed in the next major. Use MessageEmbed#addFields instead.',
nyapat marked this conversation as resolved.
Show resolved Hide resolved
'DeprecationWarning',
);

deprecationEmittedForAddField = true;
}
return this.addFields({ name, value, inline });
}

Expand Down
1 change: 1 addition & 0 deletions typings/index.d.ts
Expand Up @@ -1766,6 +1766,7 @@ export class MessageEmbed {
public url: string | null;
public readonly video: MessageEmbedVideo | null;
public addField(name: string, value: string, inline?: boolean): this;
/** @deprecated This method is a wrapper for {@link MessageEmbed.addFields}, use that instead. */
nyapat marked this conversation as resolved.
Show resolved Hide resolved
public addFields(...fields: EmbedFieldData[] | EmbedFieldData[][]): this;
public setFields(...fields: EmbedFieldData[] | EmbedFieldData[][]): this;
public setAuthor(options: EmbedAuthorData | null): this;
Expand Down