From aedddb875e740e1f1bd77f06ce1b361fd3b7bc36 Mon Sep 17 00:00:00 2001 From: Jiralite <33201955+Jiralite@users.noreply.github.com> Date: Sat, 9 Apr 2022 10:34:05 +0100 Subject: [PATCH] refactor: Remove store channels (#7634) --- ...plicationCommandOptionChannelTypesMixin.ts | 1 - packages/discord.js/package.json | 2 +- packages/discord.js/src/index.js | 1 - .../src/managers/GuildChannelManager.js | 10 ---- .../src/managers/GuildInviteManager.js | 3 +- packages/discord.js/src/structures/Channel.js | 14 ----- packages/discord.js/src/structures/Guild.js | 4 +- .../discord.js/src/structures/GuildChannel.js | 1 - .../discord.js/src/structures/StoreChannel.js | 56 ------------------- .../src/structures/WelcomeChannel.js | 2 +- packages/discord.js/typings/index.d.ts | 41 ++------------ packages/discord.js/typings/index.test-d.ts | 16 +----- yarn.lock | 9 ++- 13 files changed, 21 insertions(+), 139 deletions(-) delete mode 100644 packages/discord.js/src/structures/StoreChannel.js diff --git a/packages/builders/src/interactions/slashCommands/mixins/ApplicationCommandOptionChannelTypesMixin.ts b/packages/builders/src/interactions/slashCommands/mixins/ApplicationCommandOptionChannelTypesMixin.ts index 382cf7211af0..316da0cb425a 100644 --- a/packages/builders/src/interactions/slashCommands/mixins/ApplicationCommandOptionChannelTypesMixin.ts +++ b/packages/builders/src/interactions/slashCommands/mixins/ApplicationCommandOptionChannelTypesMixin.ts @@ -7,7 +7,6 @@ const allowedChannelTypes = [ ChannelType.GuildVoice, ChannelType.GuildCategory, ChannelType.GuildNews, - ChannelType.GuildStore, ChannelType.GuildNewsThread, ChannelType.GuildPublicThread, ChannelType.GuildPrivateThread, diff --git a/packages/discord.js/package.json b/packages/discord.js/package.json index edda72711890..8c8133dca95b 100644 --- a/packages/discord.js/package.json +++ b/packages/discord.js/package.json @@ -52,7 +52,7 @@ "@discordjs/rest": "workspace:^", "@sapphire/snowflake": "^3.1.0", "@types/ws": "^8.2.2", - "discord-api-types": "^0.29.0", + "discord-api-types": "^0.31.0", "fast-deep-equal": "^3.1.3", "lodash.snakecase": "^4.1.1", "undici": "^4.14.1", diff --git a/packages/discord.js/src/index.js b/packages/discord.js/src/index.js index 45dcc364402b..b2ee0766b779 100644 --- a/packages/discord.js/src/index.js +++ b/packages/discord.js/src/index.js @@ -147,7 +147,6 @@ exports.StageChannel = require('./structures/StageChannel'); exports.StageInstance = require('./structures/StageInstance').StageInstance; exports.Sticker = require('./structures/Sticker').Sticker; exports.StickerPack = require('./structures/StickerPack'); -exports.StoreChannel = require('./structures/StoreChannel'); exports.Team = require('./structures/Team'); exports.TeamMember = require('./structures/TeamMember'); exports.TextChannel = require('./structures/TextChannel'); diff --git a/packages/discord.js/src/managers/GuildChannelManager.js b/packages/discord.js/src/managers/GuildChannelManager.js index fca3c75fdb5e..e0be3b1eee68 100644 --- a/packages/discord.js/src/managers/GuildChannelManager.js +++ b/packages/discord.js/src/managers/GuildChannelManager.js @@ -16,7 +16,6 @@ const Util = require('../util/Util'); const { resolveAutoArchiveMaxLimit } = require('../util/Util'); let cacheWarningEmitted = false; -let storeChannelDeprecationEmitted = false; /** * Manages API methods for GuildChannels and stores their cache. @@ -145,15 +144,6 @@ class GuildChannelManager extends CachedManager { parent &&= this.client.channels.resolveId(parent); permissionOverwrites &&= permissionOverwrites.map(o => PermissionOverwrites.resolve(o, this.guild)); - if (type === ChannelType.GuildStore && !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.rest.post(Routes.guildChannels(this.guild.id), { body: { name, diff --git a/packages/discord.js/src/managers/GuildInviteManager.js b/packages/discord.js/src/managers/GuildInviteManager.js index 5b74c4749783..0764e120fc38 100644 --- a/packages/discord.js/src/managers/GuildInviteManager.js +++ b/packages/discord.js/src/managers/GuildInviteManager.js @@ -44,10 +44,9 @@ class GuildInviteManager extends CachedManager { * * TextChannel * * VoiceChannel * * NewsChannel - * * StoreChannel * * StageChannel * * Snowflake - * @typedef {TextChannel|VoiceChannel|NewsChannel|StoreChannel|StageChannel|Snowflake} + * @typedef {TextChannel|VoiceChannel|NewsChannel|StageChannel|Snowflake} * GuildInvitableChannelResolvable */ diff --git a/packages/discord.js/src/structures/Channel.js b/packages/discord.js/src/structures/Channel.js index d5fa0601b1a3..ff2277c80653 100644 --- a/packages/discord.js/src/structures/Channel.js +++ b/packages/discord.js/src/structures/Channel.js @@ -8,7 +8,6 @@ let CategoryChannel; let DMChannel; let NewsChannel; let StageChannel; -let StoreChannel; let TextChannel; let ThreadChannel; let VoiceChannel; @@ -158,14 +157,6 @@ class Channel extends Base { return this.type === ChannelType.GuildNews; } - /** - * Indicates whether this channel is a {@link StoreChannel}. - * @returns {boolean} - */ - isStore() { - return this.type === ChannelType.GuildStore; - } - /** * Indicates whether this channel is a {@link ThreadChannel}. * @returns {boolean} @@ -211,7 +202,6 @@ class Channel extends Base { DMChannel ??= require('./DMChannel'); NewsChannel ??= require('./NewsChannel'); StageChannel ??= require('./StageChannel'); - StoreChannel ??= require('./StoreChannel'); TextChannel ??= require('./TextChannel'); ThreadChannel ??= require('./ThreadChannel'); VoiceChannel ??= require('./VoiceChannel'); @@ -245,10 +235,6 @@ class Channel extends Base { channel = new NewsChannel(guild, data, client); break; } - case ChannelType.GuildStore: { - channel = new StoreChannel(guild, data, client); - break; - } case ChannelType.GuildStageVoice: { channel = new StageChannel(guild, data, client); break; diff --git a/packages/discord.js/src/structures/Guild.js b/packages/discord.js/src/structures/Guild.js index ff328bfd2709..6da0b64dd923 100644 --- a/packages/discord.js/src/structures/Guild.js +++ b/packages/discord.js/src/structures/Guild.js @@ -839,7 +839,7 @@ class Guild extends AnonymousGuild { * Welcome channel data * @typedef {Object} WelcomeChannelData * @property {string} description The description to show for this welcome channel - * @property {TextChannel|NewsChannel|StoreChannel|Snowflake} channel The channel to link for this welcome channel + * @property {GuildTextChannelResolvable} channel The channel to link for this welcome channel * @property {EmojiIdentifierResolvable} [emoji] The emoji to display for this welcome channel */ @@ -1269,7 +1269,7 @@ class Guild extends AnonymousGuild { */ _sortedChannels(channel) { const category = channel.type === ChannelType.GuildCategory; - const channelTypes = [ChannelType.GuildText, ChannelType.GuildNews, ChannelType.GuildStore]; + const channelTypes = [ChannelType.GuildText, ChannelType.GuildNews]; return Util.discordSort( this.channels.cache.filter( c => diff --git a/packages/discord.js/src/structures/GuildChannel.js b/packages/discord.js/src/structures/GuildChannel.js index 8561ec6a34ea..157d187fd28a 100644 --- a/packages/discord.js/src/structures/GuildChannel.js +++ b/packages/discord.js/src/structures/GuildChannel.js @@ -13,7 +13,6 @@ const PermissionsBitField = require('../util/PermissionsBitField'); * - {@link VoiceChannel} * - {@link CategoryChannel} * - {@link NewsChannel} - * - {@link StoreChannel} * - {@link StageChannel} * @extends {Channel} * @abstract diff --git a/packages/discord.js/src/structures/StoreChannel.js b/packages/discord.js/src/structures/StoreChannel.js deleted file mode 100644 index e8bd745fdc8c..000000000000 --- a/packages/discord.js/src/structures/StoreChannel.js +++ /dev/null @@ -1,56 +0,0 @@ -'use strict'; - -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 { - constructor(guild, data, client) { - super(guild, data, client); - - /** - * If the guild considers this channel NSFW - * @type {boolean} - */ - this.nsfw = Boolean(data.nsfw); - } - - _patch(data) { - super._patch(data); - - if ('nsfw' in data) { - this.nsfw = Boolean(data.nsfw); - } - } - - /** - * Creates an invite to this guild channel. - * @param {CreateInviteOptions} [options={}] The options for creating the invite - * @returns {Promise} - * @example - * // Create an invite to a channel - * channel.createInvite() - * .then(invite => console.log(`Created an invite with a code of ${invite.code}`)) - * .catch(console.error); - */ - createInvite(options) { - return this.guild.invites.create(this.id, options); - } - - /** - * Fetches a collection of invites to this guild channel. - * Resolves with a collection mapping invites by their codes. - * @param {boolean} [cache=true] Whether or not to cache the fetched invites - * @returns {Promise>} - */ - fetchInvites(cache = true) { - return this.guild.invites.fetch({ channelId: this.id, cache }); - } -} - -module.exports = StoreChannel; diff --git a/packages/discord.js/src/structures/WelcomeChannel.js b/packages/discord.js/src/structures/WelcomeChannel.js index 0741ab7cbb25..81f604796383 100644 --- a/packages/discord.js/src/structures/WelcomeChannel.js +++ b/packages/discord.js/src/structures/WelcomeChannel.js @@ -42,7 +42,7 @@ class WelcomeChannel extends Base { /** * The channel of this welcome channel - * @type {?(TextChannel|NewsChannel|StoreChannel)} + * @type {?(TextChannel|NewsChannel)} */ get channel() { return this.client.channels.resolve(this.channelId); diff --git a/packages/discord.js/typings/index.d.ts b/packages/discord.js/typings/index.d.ts index cb206472b7a0..ae561d30d821 100644 --- a/packages/discord.js/typings/index.d.ts +++ b/packages/discord.js/typings/index.d.ts @@ -641,7 +641,6 @@ export interface MappedChannelCategoryTypes { [ChannelType.GuildNews]: NewsChannel; [ChannelType.GuildVoice]: VoiceChannel; [ChannelType.GuildText]: TextChannel; - [ChannelType.GuildStore]: StoreChannel; [ChannelType.GuildStageVoice]: StageChannel; } @@ -678,7 +677,6 @@ export abstract class Channel extends Base { public isGroupDM(): this is PartialGroupDMChannel; public isCategory(): this is CategoryChannel; public isNews(): this is NewsChannel; - public isStore(): this is StoreChannel; public isThread(): this is ThreadChannel; public isStage(): this is StageChannel; public isTextBased(): this is TextBasedChannel; @@ -2245,17 +2243,6 @@ export class StickerPack extends Base { public bannerURL(options?: ImageURLOptions): string | null; } -/** @deprecated See [Self-serve Game Selling Deprecation](https://support-dev.discord.com/hc/en-us/articles/4414590563479) for more information */ -export class StoreChannel extends GuildChannel { - private constructor(guild: Guild, data?: RawGuildChannelData, client?: Client); - public createInvite(options?: CreateInviteOptions): Promise; - public fetchInvites(cache?: boolean): Promise>; - /** @deprecated See [Self-serve Game Selling Deprecation](https://support-dev.discord.com/hc/en-us/articles/4414590563479) for more information */ - public clone(options?: GuildChannelCloneOptions): Promise; - public nsfw: boolean; - public type: ChannelType.GuildStore; -} - export class Sweepers { public constructor(client: Client, options: SweeperOptions); public readonly client: Client; @@ -2801,7 +2788,7 @@ export class WelcomeChannel extends Base { public channelId: Snowflake; public guild: Guild | InviteGuild; public description: string; - public get channel(): TextChannel | NewsChannel | StoreChannel | null; + public get channel(): TextChannel | NewsChannel | null; public get emoji(): GuildEmoji | Emoji; } @@ -2977,15 +2964,10 @@ export class CategoryChannelChildManager extends DataManager< public channel: CategoryChannel; public get guild(): Guild; - public create>( + public create( name: string, options: CategoryCreateChannelOptions & { type: T }, ): Promise; - /** @deprecated See [Self-serve Game Selling Deprecation](https://support-dev.discord.com/hc/en-us/articles/4414590563479) for more information */ - public create( - name: string, - options: CategoryCreateChannelOptions & { type: ChannelType.GuildStore }, - ): Promise; public create(name: string, options?: CategoryCreateChannelOptions): Promise; } @@ -3020,15 +3002,10 @@ export class GuildChannelManager extends CachedManager>( + public create( name: string, options: GuildChannelCreateOptions & { type: T }, ): Promise; - /** @deprecated See [Self-serve Game Selling Deprecation](https://support-dev.discord.com/hc/en-us/articles/4414590563479) for more information */ - public create( - name: string, - options: GuildChannelCreateOptions & { type: ChannelType.GuildStore }, - ): Promise; public create(name: string, options?: GuildChannelCreateOptions): Promise; public createWebhook( channel: GuildChannelResolvable, @@ -4642,13 +4619,7 @@ export interface InviteGenerationOptions { scopes: OAuth2Scopes[]; } -export type GuildInvitableChannelResolvable = - | TextChannel - | VoiceChannel - | NewsChannel - | StoreChannel - | StageChannel - | Snowflake; +export type GuildInvitableChannelResolvable = TextChannel | VoiceChannel | NewsChannel | StageChannel | Snowflake; export interface CreateInviteOptions { temporary?: boolean; @@ -4911,7 +4882,6 @@ export interface PartialChannelData { | ChannelType.DM | ChannelType.GroupDM | ChannelType.GuildNews - | ChannelType.GuildStore | ChannelType.GuildNewsThread | ChannelType.GuildPublicThread | ChannelType.GuildPrivateThread @@ -5135,7 +5105,6 @@ export type AnyChannel = | PartialGroupDMChannel | NewsChannel | StageChannel - | StoreChannel | TextChannel | ThreadChannel | VoiceChannel; @@ -5261,7 +5230,7 @@ export interface WidgetChannel { export interface WelcomeChannelData { description: string; - channel: TextChannel | NewsChannel | StoreChannel | Snowflake; + channel: GuildTextChannelResolvable; emoji?: EmojiIdentifierResolvable; } diff --git a/packages/discord.js/typings/index.test-d.ts b/packages/discord.js/typings/index.test-d.ts index bf5d1d6b4d80..0746ff0e0daf 100644 --- a/packages/discord.js/typings/index.test-d.ts +++ b/packages/discord.js/typings/index.test-d.ts @@ -76,7 +76,6 @@ import { ShardingManager, Snowflake, StageChannel, - StoreChannel, TextBasedChannelFields, TextBasedChannel, TextBasedChannelTypes, @@ -891,7 +890,6 @@ declare const dmChannel: DMChannel; declare const threadChannel: ThreadChannel; declare const newsChannel: NewsChannel; declare const textChannel: TextChannel; -declare const storeChannel: StoreChannel; declare const voiceChannel: VoiceChannel; declare const guild: Guild; declare const user: User; @@ -910,10 +908,6 @@ expectType(threadChannel.lastMessage); expectType(newsChannel.lastMessage); expectType(textChannel.lastMessage); -expectDeprecated(storeChannel.clone()); -expectDeprecated(categoryChannelChildManager.create('Store', { type: ChannelType.GuildStore })); -expectDeprecated(guild.channels.create('Store', { type: ChannelType.GuildStore })); - notPropertyOf(user, 'lastMessage'); notPropertyOf(user, 'lastMessageId'); notPropertyOf(guildMember, 'lastMessage'); @@ -996,7 +990,6 @@ declare const categoryChannelChildManager: CategoryChannelChildManager; expectType>(categoryChannelChildManager.create('name', { type: ChannelType.GuildVoice })); expectType>(categoryChannelChildManager.create('name', { type: ChannelType.GuildText })); expectType>(categoryChannelChildManager.create('name', { type: ChannelType.GuildNews })); - expectDeprecated(categoryChannelChildManager.create('name', { type: ChannelType.GuildStore })); expectType>(categoryChannelChildManager.create('name', { type: ChannelType.GuildStageVoice })); expectType>(categoryChannelChildManager.create('name', {})); expectType>(categoryChannelChildManager.create('name')); @@ -1004,7 +997,7 @@ declare const categoryChannelChildManager: CategoryChannelChildManager; declare const guildChannelManager: GuildChannelManager; { - type AnyChannel = TextChannel | VoiceChannel | CategoryChannel | NewsChannel | StoreChannel | StageChannel; + type AnyChannel = TextChannel | VoiceChannel | CategoryChannel | NewsChannel | StageChannel; expectType>(guildChannelManager.create('name')); expectType>(guildChannelManager.create('name', {})); @@ -1012,7 +1005,6 @@ declare const guildChannelManager: GuildChannelManager; expectType>(guildChannelManager.create('name', { type: ChannelType.GuildCategory })); expectType>(guildChannelManager.create('name', { type: ChannelType.GuildText })); expectType>(guildChannelManager.create('name', { type: ChannelType.GuildNews })); - expectType>(guildChannelManager.create('name', { type: ChannelType.GuildStore })); expectType>(guildChannelManager.create('name', { type: ChannelType.GuildStageVoice })); expectType>>(guildChannelManager.fetch()); @@ -1371,12 +1363,10 @@ declare const GuildTextBasedChannel: GuildTextBasedChannel; expectType(TextBasedChannel); expectType(TextBasedChannelTypes); expectType(VoiceBasedChannel); -expectType( +expectType( GuildBasedChannel, ); -expectType( - NonThreadGuildBasedChannel, -); +expectType(NonThreadGuildBasedChannel); expectType(GuildTextBasedChannel); const button = new ButtonBuilder({ diff --git a/yarn.lock b/yarn.lock index 8c9a405c9f56..9caddb7ad29d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4422,6 +4422,13 @@ __metadata: languageName: node linkType: hard +"discord-api-types@npm:^0.31.0": + version: 0.31.0 + resolution: "discord-api-types@npm:0.31.0" + checksum: 7ac466df8f3b62ebfa18296ef8cbf7a35ae295b775184b01f4357409cff89aa4e85a67e7fb3363b4a4ff796ff7313865e0266706b3d7908ef2238147a196a806 + languageName: node + linkType: hard + "discord.js@workspace:packages/discord.js": version: 0.0.0-use.local resolution: "discord.js@workspace:packages/discord.js" @@ -4433,7 +4440,7 @@ __metadata: "@sapphire/snowflake": ^3.1.0 "@types/node": ^16.11.24 "@types/ws": ^8.2.2 - discord-api-types: ^0.29.0 + discord-api-types: ^0.31.0 dtslint: ^4.2.1 eslint: ^8.9.0 eslint-config-prettier: ^8.3.0