diff --git a/src/structures/Guild.js b/src/structures/Guild.js index 0b566f95b..7ee47e576 100644 --- a/src/structures/Guild.js +++ b/src/structures/Guild.js @@ -34,6 +34,9 @@ const DataResolver = require('../util/DataResolver'); const SystemChannelFlags = require('../util/SystemChannelFlags'); const Util = require('../util/Util'); +let deprecationEmittedForSetChannelPositions = false; +let deprecationEmittedForSetRolePositions = false; + /** * Represents a guild (or a server) on Discord. * It's recommended to see if a guild is available before performing operations or reading data from it. You can @@ -1195,6 +1198,15 @@ class Guild extends AnonymousGuild { * .catch(console.error); */ setChannelPositions(channelPositions) { + if (!deprecationEmittedForSetChannelPositions) { + process.emitWarning( + 'The Guild#setChannelPositions method is deprecated. Use GuildChannelManager#setPositions instead.', + 'DeprecationWarning', + ); + + deprecationEmittedForSetChannelPositions = true; + } + return this.channels.setPositions(channelPositions); } @@ -1216,6 +1228,15 @@ class Guild extends AnonymousGuild { * .catch(console.error); */ setRolePositions(rolePositions) { + if (!deprecationEmittedForSetRolePositions) { + process.emitWarning( + 'The Guild#setRolePositions method is deprecated. Use RoleManager#setPositions instead.', + 'DeprecationWarning', + ); + + deprecationEmittedForSetRolePositions = true; + } + return this.roles.setPositions(rolePositions); } diff --git a/src/structures/MessageEmbed.js b/src/structures/MessageEmbed.js index ce7334a33..382333430 100644 --- a/src/structures/MessageEmbed.js +++ b/src/structures/MessageEmbed.js @@ -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 }; } diff --git a/src/structures/VoiceChannel.js b/src/structures/VoiceChannel.js index 64cc6c50c..9b5850788 100644 --- a/src/structures/VoiceChannel.js +++ b/src/structures/VoiceChannel.js @@ -3,6 +3,8 @@ const BaseGuildVoiceChannel = require('./BaseGuildVoiceChannel'); const Permissions = require('../util/Permissions'); +let deprecationEmittedForEditable = false; + /** * Represents a guild voice channel on Discord. * @extends {BaseGuildVoiceChannel} @@ -15,6 +17,15 @@ class VoiceChannel extends BaseGuildVoiceChannel { * @deprecated Use {@link VoiceChannel#manageable} instead */ get editable() { + if (!deprecationEmittedForEditable) { + process.emitWarning( + 'The VoiceChannel#editable getter is deprecated. Use VoiceChannel#manageable instead.', + 'DeprecationWarning', + ); + + deprecationEmittedForEditable = true; + } + return this.manageable; } diff --git a/src/structures/Webhook.js b/src/structures/Webhook.js index c27244b29..a10f5d2df 100644 --- a/src/structures/Webhook.js +++ b/src/structures/Webhook.js @@ -6,6 +6,8 @@ const { WebhookTypes } = require('../util/Constants'); const DataResolver = require('../util/DataResolver'); const SnowflakeUtil = require('../util/SnowflakeUtil'); +let deprecationEmittedForFetchMessage = false; + /** * Represents a webhook. */ @@ -270,12 +272,21 @@ class Webhook { * Gets a message that was sent by this webhook. * @param {Snowflake|'@original'} message The id of the message to fetch * @param {WebhookFetchMessageOptions|boolean} [cacheOrOptions={}] The options to provide to fetch the message. - * A **deprecated** boolean may be passed instead to specify whether to cache the message. + * A **deprecated** boolean may be passed instead to specify whether to cache the message. * @returns {Promise} Returns the raw message data if the webhook was instantiated as a * {@link WebhookClient} or if the channel is uncached, otherwise a {@link Message} will be returned */ async fetchMessage(message, cacheOrOptions = { cache: true }) { if (typeof cacheOrOptions === 'boolean') { + if (!deprecationEmittedForFetchMessage) { + process.emitWarning( + 'Passing a boolean to cache the message in Webhook#fetchMessage is deprecated. Pass an object instead.', + 'DeprecationWarning', + ); + + deprecationEmittedForFetchMessage = true; + } + cacheOrOptions = { cache: cacheOrOptions }; } diff --git a/src/util/Util.js b/src/util/Util.js index 55e3b2b52..2c6cbb2da 100644 --- a/src/util/Util.js +++ b/src/util/Util.js @@ -9,6 +9,8 @@ const { Error: DiscordError, RangeError, TypeError } = require('../errors'); const has = (o, k) => Object.prototype.hasOwnProperty.call(o, k); const isObject = d => typeof d === 'object' && d !== null; +let deprecationEmittedForRemoveMentions = false; + /** * Contains various general-purpose utility methods. */ @@ -578,6 +580,15 @@ class Util extends null { * @deprecated Use {@link BaseMessageOptions#allowedMentions} instead. */ static removeMentions(str) { + if (!deprecationEmittedForRemoveMentions) { + process.emitWarning( + 'The Util.removeMentions method is deprecated. Use MessageOptions#allowedMentions instead.', + 'DeprecationWarning', + ); + + deprecationEmittedForRemoveMentions = true; + } + return str.replaceAll('@', '@\u200b'); }