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.GuildCategory,
ChannelType.GuildNews,
ChannelType.GuildStore,
ChannelType.GuildNewsThread,
ChannelType.GuildPublicThread,
ChannelType.GuildPrivateThread,

View File

@@ -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",

View File

@@ -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');

View File

@@ -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,

View File

@@ -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
*/

View File

@@ -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;

View File

@@ -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 =>

View File

@@ -13,7 +13,6 @@ const PermissionsBitField = require('../util/PermissionsBitField');
* - {@link VoiceChannel}
* - {@link CategoryChannel}
* - {@link NewsChannel}
* - {@link StoreChannel}
* - {@link StageChannel}
* @extends {Channel}
* @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
* @type {?(TextChannel|NewsChannel|StoreChannel)}
* @type {?(TextChannel|NewsChannel)}
*/
get channel() {
return this.client.channels.resolve(this.channelId);

View File

@@ -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<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 {
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<T extends Exclude<CategoryChannelType, ChannelType.GuildStore>>(
public create<T extends CategoryChannelType>(
name: string,
options: CategoryCreateChannelOptions & { type: 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>;
}
@@ -3020,15 +3002,10 @@ export class GuildChannelManager extends CachedManager<Snowflake, GuildBasedChan
public get channelCountWithoutThreads(): number;
public guild: Guild;
public create<T extends Exclude<GuildChannelTypes, ChannelType.GuildStore>>(
public create<T extends GuildChannelTypes>(
name: string,
options: GuildChannelCreateOptions & { type: 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 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;
}

View File

@@ -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<Message | null>(threadChannel.lastMessage);
expectType<Message | null>(newsChannel.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, 'lastMessageId');
notPropertyOf(guildMember, 'lastMessage');
@@ -996,7 +990,6 @@ declare const categoryChannelChildManager: CategoryChannelChildManager;
expectType<Promise<VoiceChannel>>(categoryChannelChildManager.create('name', { type: ChannelType.GuildVoice }));
expectType<Promise<TextChannel>>(categoryChannelChildManager.create('name', { type: ChannelType.GuildText }));
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<TextChannel>>(categoryChannelChildManager.create('name', {}));
expectType<Promise<TextChannel>>(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<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<TextChannel>>(guildChannelManager.create('name', { type: ChannelType.GuildText }));
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<Collection<Snowflake, AnyChannel>>>(guildChannelManager.fetch());
@@ -1371,12 +1363,10 @@ declare const GuildTextBasedChannel: GuildTextBasedChannel;
expectType<DMChannel | PartialDMChannel | NewsChannel | TextChannel | ThreadChannel>(TextBasedChannel);
expectType<ChannelType.GuildText | ChannelType.DM | ChannelType.GuildNews | ThreadChannelType>(TextBasedChannelTypes);
expectType<StageChannel | VoiceChannel>(VoiceBasedChannel);
expectType<CategoryChannel | NewsChannel | StageChannel | StoreChannel | TextChannel | ThreadChannel | VoiceChannel>(
expectType<CategoryChannel | NewsChannel | StageChannel | TextChannel | ThreadChannel | VoiceChannel>(
GuildBasedChannel,
);
expectType<CategoryChannel | NewsChannel | StageChannel | StoreChannel | TextChannel | VoiceChannel>(
NonThreadGuildBasedChannel,
);
expectType<CategoryChannel | NewsChannel | StageChannel | TextChannel | VoiceChannel>(NonThreadGuildBasedChannel);
expectType<NewsChannel | TextChannel | ThreadChannel>(GuildTextBasedChannel);
const button = new ButtonBuilder({

View File

@@ -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