refactor: Remove store channels (#7634)

This commit is contained in:
Jiralite
2022-04-09 10:34:05 +01:00
committed by GitHub
parent 402514ff32
commit aedddb875e
13 changed files with 21 additions and 139 deletions

View File

@@ -7,7 +7,6 @@ const allowedChannelTypes = [
ChannelType.GuildVoice, ChannelType.GuildVoice,
ChannelType.GuildCategory, ChannelType.GuildCategory,
ChannelType.GuildNews, ChannelType.GuildNews,
ChannelType.GuildStore,
ChannelType.GuildNewsThread, ChannelType.GuildNewsThread,
ChannelType.GuildPublicThread, ChannelType.GuildPublicThread,
ChannelType.GuildPrivateThread, ChannelType.GuildPrivateThread,

View File

@@ -52,7 +52,7 @@
"@discordjs/rest": "workspace:^", "@discordjs/rest": "workspace:^",
"@sapphire/snowflake": "^3.1.0", "@sapphire/snowflake": "^3.1.0",
"@types/ws": "^8.2.2", "@types/ws": "^8.2.2",
"discord-api-types": "^0.29.0", "discord-api-types": "^0.31.0",
"fast-deep-equal": "^3.1.3", "fast-deep-equal": "^3.1.3",
"lodash.snakecase": "^4.1.1", "lodash.snakecase": "^4.1.1",
"undici": "^4.14.1", "undici": "^4.14.1",

View File

@@ -147,7 +147,6 @@ exports.StageChannel = require('./structures/StageChannel');
exports.StageInstance = require('./structures/StageInstance').StageInstance; exports.StageInstance = require('./structures/StageInstance').StageInstance;
exports.Sticker = require('./structures/Sticker').Sticker; exports.Sticker = require('./structures/Sticker').Sticker;
exports.StickerPack = require('./structures/StickerPack'); exports.StickerPack = require('./structures/StickerPack');
exports.StoreChannel = require('./structures/StoreChannel');
exports.Team = require('./structures/Team'); exports.Team = require('./structures/Team');
exports.TeamMember = require('./structures/TeamMember'); exports.TeamMember = require('./structures/TeamMember');
exports.TextChannel = require('./structures/TextChannel'); exports.TextChannel = require('./structures/TextChannel');

View File

@@ -16,7 +16,6 @@ const Util = require('../util/Util');
const { resolveAutoArchiveMaxLimit } = require('../util/Util'); const { resolveAutoArchiveMaxLimit } = require('../util/Util');
let cacheWarningEmitted = false; let cacheWarningEmitted = false;
let storeChannelDeprecationEmitted = false;
/** /**
* Manages API methods for GuildChannels and stores their cache. * Manages API methods for GuildChannels and stores their cache.
@@ -145,15 +144,6 @@ class GuildChannelManager extends CachedManager {
parent &&= this.client.channels.resolveId(parent); parent &&= this.client.channels.resolveId(parent);
permissionOverwrites &&= permissionOverwrites.map(o => PermissionOverwrites.resolve(o, this.guild)); 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), { const data = await this.client.rest.post(Routes.guildChannels(this.guild.id), {
body: { body: {
name, name,

View File

@@ -44,10 +44,9 @@ class GuildInviteManager extends CachedManager {
* * TextChannel * * TextChannel
* * VoiceChannel * * VoiceChannel
* * NewsChannel * * NewsChannel
* * StoreChannel
* * StageChannel * * StageChannel
* * Snowflake * * Snowflake
* @typedef {TextChannel|VoiceChannel|NewsChannel|StoreChannel|StageChannel|Snowflake} * @typedef {TextChannel|VoiceChannel|NewsChannel|StageChannel|Snowflake}
* GuildInvitableChannelResolvable * GuildInvitableChannelResolvable
*/ */

View File

@@ -8,7 +8,6 @@ let CategoryChannel;
let DMChannel; let DMChannel;
let NewsChannel; let NewsChannel;
let StageChannel; let StageChannel;
let StoreChannel;
let TextChannel; let TextChannel;
let ThreadChannel; let ThreadChannel;
let VoiceChannel; let VoiceChannel;
@@ -158,14 +157,6 @@ class Channel extends Base {
return this.type === ChannelType.GuildNews; 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}. * Indicates whether this channel is a {@link ThreadChannel}.
* @returns {boolean} * @returns {boolean}
@@ -211,7 +202,6 @@ class Channel extends Base {
DMChannel ??= require('./DMChannel'); DMChannel ??= require('./DMChannel');
NewsChannel ??= require('./NewsChannel'); NewsChannel ??= require('./NewsChannel');
StageChannel ??= require('./StageChannel'); StageChannel ??= require('./StageChannel');
StoreChannel ??= require('./StoreChannel');
TextChannel ??= require('./TextChannel'); TextChannel ??= require('./TextChannel');
ThreadChannel ??= require('./ThreadChannel'); ThreadChannel ??= require('./ThreadChannel');
VoiceChannel ??= require('./VoiceChannel'); VoiceChannel ??= require('./VoiceChannel');
@@ -245,10 +235,6 @@ class Channel extends Base {
channel = new NewsChannel(guild, data, client); channel = new NewsChannel(guild, data, client);
break; break;
} }
case ChannelType.GuildStore: {
channel = new StoreChannel(guild, data, client);
break;
}
case ChannelType.GuildStageVoice: { case ChannelType.GuildStageVoice: {
channel = new StageChannel(guild, data, client); channel = new StageChannel(guild, data, client);
break; break;

View File

@@ -839,7 +839,7 @@ class Guild extends AnonymousGuild {
* Welcome channel data * Welcome channel data
* @typedef {Object} WelcomeChannelData * @typedef {Object} WelcomeChannelData
* @property {string} description The description to show for this welcome channel * @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 * @property {EmojiIdentifierResolvable} [emoji] The emoji to display for this welcome channel
*/ */
@@ -1269,7 +1269,7 @@ class Guild extends AnonymousGuild {
*/ */
_sortedChannels(channel) { _sortedChannels(channel) {
const category = channel.type === ChannelType.GuildCategory; const category = channel.type === ChannelType.GuildCategory;
const channelTypes = [ChannelType.GuildText, ChannelType.GuildNews, ChannelType.GuildStore]; const channelTypes = [ChannelType.GuildText, ChannelType.GuildNews];
return Util.discordSort( return Util.discordSort(
this.channels.cache.filter( this.channels.cache.filter(
c => c =>

View File

@@ -13,7 +13,6 @@ const PermissionsBitField = require('../util/PermissionsBitField');
* - {@link VoiceChannel} * - {@link VoiceChannel}
* - {@link CategoryChannel} * - {@link CategoryChannel}
* - {@link NewsChannel} * - {@link NewsChannel}
* - {@link StoreChannel}
* - {@link StageChannel} * - {@link StageChannel}
* @extends {Channel} * @extends {Channel}
* @abstract * @abstract

View File

@@ -1,56 +0,0 @@
'use strict';
const GuildChannel = require('./GuildChannel');
/**
* Represents a guild store channel on Discord.
* <warn>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.</warn>
* @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<Invite>}
* @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<Collection<string, Invite>>}
*/
fetchInvites(cache = true) {
return this.guild.invites.fetch({ channelId: this.id, cache });
}
}
module.exports = StoreChannel;

View File

@@ -42,7 +42,7 @@ class WelcomeChannel extends Base {
/** /**
* The channel of this welcome channel * The channel of this welcome channel
* @type {?(TextChannel|NewsChannel|StoreChannel)} * @type {?(TextChannel|NewsChannel)}
*/ */
get channel() { get channel() {
return this.client.channels.resolve(this.channelId); return this.client.channels.resolve(this.channelId);

View File

@@ -641,7 +641,6 @@ export interface MappedChannelCategoryTypes {
[ChannelType.GuildNews]: NewsChannel; [ChannelType.GuildNews]: NewsChannel;
[ChannelType.GuildVoice]: VoiceChannel; [ChannelType.GuildVoice]: VoiceChannel;
[ChannelType.GuildText]: TextChannel; [ChannelType.GuildText]: TextChannel;
[ChannelType.GuildStore]: StoreChannel;
[ChannelType.GuildStageVoice]: StageChannel; [ChannelType.GuildStageVoice]: StageChannel;
} }
@@ -678,7 +677,6 @@ export abstract class Channel extends Base {
public isGroupDM(): this is PartialGroupDMChannel; public isGroupDM(): this is PartialGroupDMChannel;
public isCategory(): this is CategoryChannel; public isCategory(): this is CategoryChannel;
public isNews(): this is NewsChannel; public isNews(): this is NewsChannel;
public isStore(): this is StoreChannel;
public isThread(): this is ThreadChannel; public isThread(): this is ThreadChannel;
public isStage(): this is StageChannel; public isStage(): this is StageChannel;
public isTextBased(): this is TextBasedChannel; public isTextBased(): this is TextBasedChannel;
@@ -2245,17 +2243,6 @@ export class StickerPack extends Base {
public bannerURL(options?: ImageURLOptions): string | null; 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<Invite>;
public fetchInvites(cache?: boolean): Promise<Collection<string, Invite>>;
/** @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<this>;
public nsfw: boolean;
public type: ChannelType.GuildStore;
}
export class Sweepers { export class Sweepers {
public constructor(client: Client, options: SweeperOptions); public constructor(client: Client, options: SweeperOptions);
public readonly client: Client; public readonly client: Client;
@@ -2801,7 +2788,7 @@ export class WelcomeChannel extends Base {
public channelId: Snowflake; public channelId: Snowflake;
public guild: Guild | InviteGuild; public guild: Guild | InviteGuild;
public description: string; public description: string;
public get channel(): TextChannel | NewsChannel | StoreChannel | null; public get channel(): TextChannel | NewsChannel | null;
public get emoji(): GuildEmoji | Emoji; public get emoji(): GuildEmoji | Emoji;
} }
@@ -2977,15 +2964,10 @@ export class CategoryChannelChildManager extends DataManager<
public channel: CategoryChannel; public channel: CategoryChannel;
public get guild(): Guild; public get guild(): Guild;
public create<T extends Exclude<CategoryChannelType, ChannelType.GuildStore>>( public create<T extends CategoryChannelType>(
name: string, name: string,
options: CategoryCreateChannelOptions & { type: T }, options: CategoryCreateChannelOptions & { type: T },
): Promise<MappedChannelCategoryTypes[T]>; ): Promise<MappedChannelCategoryTypes[T]>;
/** @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<StoreChannel>;
public create(name: string, options?: CategoryCreateChannelOptions): Promise<TextChannel>; public create(name: string, options?: CategoryCreateChannelOptions): Promise<TextChannel>;
} }
@@ -3020,15 +3002,10 @@ export class GuildChannelManager extends CachedManager<Snowflake, GuildBasedChan
public get channelCountWithoutThreads(): number; public get channelCountWithoutThreads(): number;
public guild: Guild; public guild: Guild;
public create<T extends Exclude<GuildChannelTypes, ChannelType.GuildStore>>( public create<T extends GuildChannelTypes>(
name: string, name: string,
options: GuildChannelCreateOptions & { type: T }, options: GuildChannelCreateOptions & { type: T },
): Promise<MappedGuildChannelTypes[T]>; ): Promise<MappedGuildChannelTypes[T]>;
/** @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<StoreChannel>;
public create(name: string, options?: GuildChannelCreateOptions): Promise<TextChannel>; public create(name: string, options?: GuildChannelCreateOptions): Promise<TextChannel>;
public createWebhook( public createWebhook(
channel: GuildChannelResolvable, channel: GuildChannelResolvable,
@@ -4642,13 +4619,7 @@ export interface InviteGenerationOptions {
scopes: OAuth2Scopes[]; scopes: OAuth2Scopes[];
} }
export type GuildInvitableChannelResolvable = export type GuildInvitableChannelResolvable = TextChannel | VoiceChannel | NewsChannel | StageChannel | Snowflake;
| TextChannel
| VoiceChannel
| NewsChannel
| StoreChannel
| StageChannel
| Snowflake;
export interface CreateInviteOptions { export interface CreateInviteOptions {
temporary?: boolean; temporary?: boolean;
@@ -4911,7 +4882,6 @@ export interface PartialChannelData {
| ChannelType.DM | ChannelType.DM
| ChannelType.GroupDM | ChannelType.GroupDM
| ChannelType.GuildNews | ChannelType.GuildNews
| ChannelType.GuildStore
| ChannelType.GuildNewsThread | ChannelType.GuildNewsThread
| ChannelType.GuildPublicThread | ChannelType.GuildPublicThread
| ChannelType.GuildPrivateThread | ChannelType.GuildPrivateThread
@@ -5135,7 +5105,6 @@ export type AnyChannel =
| PartialGroupDMChannel | PartialGroupDMChannel
| NewsChannel | NewsChannel
| StageChannel | StageChannel
| StoreChannel
| TextChannel | TextChannel
| ThreadChannel | ThreadChannel
| VoiceChannel; | VoiceChannel;
@@ -5261,7 +5230,7 @@ export interface WidgetChannel {
export interface WelcomeChannelData { export interface WelcomeChannelData {
description: string; description: string;
channel: TextChannel | NewsChannel | StoreChannel | Snowflake; channel: GuildTextChannelResolvable;
emoji?: EmojiIdentifierResolvable; emoji?: EmojiIdentifierResolvable;
} }

View File

@@ -76,7 +76,6 @@ import {
ShardingManager, ShardingManager,
Snowflake, Snowflake,
StageChannel, StageChannel,
StoreChannel,
TextBasedChannelFields, TextBasedChannelFields,
TextBasedChannel, TextBasedChannel,
TextBasedChannelTypes, TextBasedChannelTypes,
@@ -891,7 +890,6 @@ declare const dmChannel: DMChannel;
declare const threadChannel: ThreadChannel; declare const threadChannel: ThreadChannel;
declare const newsChannel: NewsChannel; declare const newsChannel: NewsChannel;
declare const textChannel: TextChannel; declare const textChannel: TextChannel;
declare const storeChannel: StoreChannel;
declare const voiceChannel: VoiceChannel; declare const voiceChannel: VoiceChannel;
declare const guild: Guild; declare const guild: Guild;
declare const user: User; declare const user: User;
@@ -910,10 +908,6 @@ expectType<Message | null>(threadChannel.lastMessage);
expectType<Message | null>(newsChannel.lastMessage); expectType<Message | null>(newsChannel.lastMessage);
expectType<Message | null>(textChannel.lastMessage); expectType<Message | null>(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, 'lastMessage');
notPropertyOf(user, 'lastMessageId'); notPropertyOf(user, 'lastMessageId');
notPropertyOf(guildMember, 'lastMessage'); notPropertyOf(guildMember, 'lastMessage');
@@ -996,7 +990,6 @@ declare const categoryChannelChildManager: CategoryChannelChildManager;
expectType<Promise<VoiceChannel>>(categoryChannelChildManager.create('name', { type: ChannelType.GuildVoice })); expectType<Promise<VoiceChannel>>(categoryChannelChildManager.create('name', { type: ChannelType.GuildVoice }));
expectType<Promise<TextChannel>>(categoryChannelChildManager.create('name', { type: ChannelType.GuildText })); expectType<Promise<TextChannel>>(categoryChannelChildManager.create('name', { type: ChannelType.GuildText }));
expectType<Promise<NewsChannel>>(categoryChannelChildManager.create('name', { type: ChannelType.GuildNews })); expectType<Promise<NewsChannel>>(categoryChannelChildManager.create('name', { type: ChannelType.GuildNews }));
expectDeprecated(categoryChannelChildManager.create('name', { type: ChannelType.GuildStore }));
expectType<Promise<StageChannel>>(categoryChannelChildManager.create('name', { type: ChannelType.GuildStageVoice })); expectType<Promise<StageChannel>>(categoryChannelChildManager.create('name', { type: ChannelType.GuildStageVoice }));
expectType<Promise<TextChannel>>(categoryChannelChildManager.create('name', {})); expectType<Promise<TextChannel>>(categoryChannelChildManager.create('name', {}));
expectType<Promise<TextChannel>>(categoryChannelChildManager.create('name')); expectType<Promise<TextChannel>>(categoryChannelChildManager.create('name'));
@@ -1004,7 +997,7 @@ declare const categoryChannelChildManager: CategoryChannelChildManager;
declare const guildChannelManager: GuildChannelManager; declare const guildChannelManager: GuildChannelManager;
{ {
type AnyChannel = TextChannel | VoiceChannel | CategoryChannel | NewsChannel | StoreChannel | StageChannel; type AnyChannel = TextChannel | VoiceChannel | CategoryChannel | NewsChannel | StageChannel;
expectType<Promise<TextChannel>>(guildChannelManager.create('name')); expectType<Promise<TextChannel>>(guildChannelManager.create('name'));
expectType<Promise<TextChannel>>(guildChannelManager.create('name', {})); expectType<Promise<TextChannel>>(guildChannelManager.create('name', {}));
@@ -1012,7 +1005,6 @@ declare const guildChannelManager: GuildChannelManager;
expectType<Promise<CategoryChannel>>(guildChannelManager.create('name', { type: ChannelType.GuildCategory })); expectType<Promise<CategoryChannel>>(guildChannelManager.create('name', { type: ChannelType.GuildCategory }));
expectType<Promise<TextChannel>>(guildChannelManager.create('name', { type: ChannelType.GuildText })); expectType<Promise<TextChannel>>(guildChannelManager.create('name', { type: ChannelType.GuildText }));
expectType<Promise<NewsChannel>>(guildChannelManager.create('name', { type: ChannelType.GuildNews })); expectType<Promise<NewsChannel>>(guildChannelManager.create('name', { type: ChannelType.GuildNews }));
expectType<Promise<StoreChannel>>(guildChannelManager.create('name', { type: ChannelType.GuildStore }));
expectType<Promise<StageChannel>>(guildChannelManager.create('name', { type: ChannelType.GuildStageVoice })); expectType<Promise<StageChannel>>(guildChannelManager.create('name', { type: ChannelType.GuildStageVoice }));
expectType<Promise<Collection<Snowflake, AnyChannel>>>(guildChannelManager.fetch()); expectType<Promise<Collection<Snowflake, AnyChannel>>>(guildChannelManager.fetch());
@@ -1371,12 +1363,10 @@ declare const GuildTextBasedChannel: GuildTextBasedChannel;
expectType<DMChannel | PartialDMChannel | NewsChannel | TextChannel | ThreadChannel>(TextBasedChannel); expectType<DMChannel | PartialDMChannel | NewsChannel | TextChannel | ThreadChannel>(TextBasedChannel);
expectType<ChannelType.GuildText | ChannelType.DM | ChannelType.GuildNews | ThreadChannelType>(TextBasedChannelTypes); expectType<ChannelType.GuildText | ChannelType.DM | ChannelType.GuildNews | ThreadChannelType>(TextBasedChannelTypes);
expectType<StageChannel | VoiceChannel>(VoiceBasedChannel); expectType<StageChannel | VoiceChannel>(VoiceBasedChannel);
expectType<CategoryChannel | NewsChannel | StageChannel | StoreChannel | TextChannel | ThreadChannel | VoiceChannel>( expectType<CategoryChannel | NewsChannel | StageChannel | TextChannel | ThreadChannel | VoiceChannel>(
GuildBasedChannel, GuildBasedChannel,
); );
expectType<CategoryChannel | NewsChannel | StageChannel | StoreChannel | TextChannel | VoiceChannel>( expectType<CategoryChannel | NewsChannel | StageChannel | TextChannel | VoiceChannel>(NonThreadGuildBasedChannel);
NonThreadGuildBasedChannel,
);
expectType<NewsChannel | TextChannel | ThreadChannel>(GuildTextBasedChannel); expectType<NewsChannel | TextChannel | ThreadChannel>(GuildTextBasedChannel);
const button = new ButtonBuilder({ const button = new ButtonBuilder({

View File

@@ -4422,6 +4422,13 @@ __metadata:
languageName: node languageName: node
linkType: hard 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": "discord.js@workspace:packages/discord.js":
version: 0.0.0-use.local version: 0.0.0-use.local
resolution: "discord.js@workspace:packages/discord.js" resolution: "discord.js@workspace:packages/discord.js"
@@ -4433,7 +4440,7 @@ __metadata:
"@sapphire/snowflake": ^3.1.0 "@sapphire/snowflake": ^3.1.0
"@types/node": ^16.11.24 "@types/node": ^16.11.24
"@types/ws": ^8.2.2 "@types/ws": ^8.2.2
discord-api-types: ^0.29.0 discord-api-types: ^0.31.0
dtslint: ^4.2.1 dtslint: ^4.2.1
eslint: ^8.9.0 eslint: ^8.9.0
eslint-config-prettier: ^8.3.0 eslint-config-prettier: ^8.3.0