From fdba146f9bd9f2743041f6302ca5e38e26c8dc44 Mon Sep 17 00:00:00 2001 From: Rodry <38259440+ImRodry@users.noreply.github.com> Date: Wed, 8 Dec 2021 17:51:07 +0000 Subject: [PATCH] docs(StoreChannel): add deprecation warnings (#7080) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Antonio Román --- src/managers/GuildChannelManager.js | 13 ++++++++++++- src/structures/StoreChannel.js | 3 +++ src/util/Constants.js | 3 +++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/managers/GuildChannelManager.js b/src/managers/GuildChannelManager.js index 89ed310e1..658d3a100 100644 --- a/src/managers/GuildChannelManager.js +++ b/src/managers/GuildChannelManager.js @@ -10,6 +10,7 @@ const ThreadChannel = require('../structures/ThreadChannel'); const { ChannelTypes, ThreadChannelTypes } = require('../util/Constants'); let cacheWarningEmitted = false; +let storeChannelDeprecationEmitted = false; /** * Manages API methods for GuildChannels and stores their cache. @@ -137,12 +138,22 @@ class GuildChannelManager extends CachedManager { ) { parent &&= this.client.channels.resolveId(parent); permissionOverwrites &&= permissionOverwrites.map(o => PermissionOverwrites.resolve(o, this.guild)); + const intType = typeof type === 'number' ? type : ChannelTypes[type] ?? ChannelTypes.GUILD_TEXT; + + if (intType === ChannelTypes.GUILD_STORE && !storeChannelDeprecationEmitted) { + storeChannelDeprecationEmitted = true; + process.emitWarning( + // eslint-disable-next-line max-len + 'Creating store channels is deprecated by Discord and will stop working in March 2022. Check the docs for more info.', + 'DeprecationWarning', + ); + } const data = await this.client.api.guilds(this.guild.id).channels.post({ data: { name, topic, - type: typeof type === 'number' ? type : ChannelTypes[type] ?? ChannelTypes.GUILD_TEXT, + type: intType, nsfw, bitrate, user_limit: userLimit, diff --git a/src/structures/StoreChannel.js b/src/structures/StoreChannel.js index bd4bd5602..e8bd745fd 100644 --- a/src/structures/StoreChannel.js +++ b/src/structures/StoreChannel.js @@ -4,6 +4,9 @@ const GuildChannel = require('./GuildChannel'); /** * Represents a guild store channel on Discord. + * Store channels are deprecated and will be removed from Discord in March 2022. See + * [Self-serve Game Selling Deprecation](https://support-dev.discord.com/hc/en-us/articles/4414590563479) + * for more information. * @extends {GuildChannel} */ class StoreChannel extends GuildChannel { diff --git a/src/util/Constants.js b/src/util/Constants.js index 5c9fab36c..caff36b48 100644 --- a/src/util/Constants.js +++ b/src/util/Constants.js @@ -465,6 +465,9 @@ exports.ActivityTypes = createEnum(['PLAYING', 'STREAMING', 'LISTENING', 'WATCHI * * `GROUP_DM` - a group DM channel * * `GUILD_CATEGORY` - a guild category channel * * `GUILD_NEWS` - a guild news channel + * Store channels are deprecated and will be removed from Discord in March 2022. See + * [Self-serve Game Selling Deprecation](https://support-dev.discord.com/hc/en-us/articles/4414590563479) + * for more information. * * `GUILD_STORE` - a guild store channel * * `GUILD_NEWS_THREAD` - a guild news channel's public thread channel * * `GUILD_PUBLIC_THREAD` - a guild text channel's public thread channel