chore: Emit deprecation messages (#6994)

This commit is contained in:
Jiralite
2021-11-23 09:29:45 +00:00
committed by GitHub
parent 7efeff461f
commit 2a0dedf3e9
5 changed files with 70 additions and 1 deletions

View File

@@ -3,6 +3,8 @@
const { RangeError } = require('../errors');
const Util = require('../util/Util');
let deprecationEmittedForSetAuthor = false;
/**
* Represents an embed in a message (image/video preview, rich embed, etc.)
*/
@@ -372,6 +374,19 @@ class MessageEmbed {
}
if (typeof options === 'string') {
if (
!deprecationEmittedForSetAuthor &&
(typeof deprecatedIconURL !== 'undefined' || typeof deprecatedURL !== 'undefined')
) {
process.emitWarning(
// eslint-disable-next-line max-len
"Passing strings for the URL or the icon's URL for MessageEmbed#setAuthor is deprecated. Pass a sole object instead.",
'DeprecationWarning',
);
deprecationEmittedForSetAuthor = true;
}
options = { name: options, url: deprecatedURL, iconURL: deprecatedIconURL };
}