refactor(embed): deprecate addField

#8318 v13.9.1
This commit is contained in:
March 7th
2022-07-26 09:57:57 +07:00
parent aecc7edec5
commit a3f8f9f0fa
2 changed files with 13 additions and 1 deletions

View File

@@ -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 });
}