Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Remove store channels #7634

Merged
merged 8 commits into from
Apr 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ const allowedChannelTypes = [
ChannelType.GuildVoice,
ChannelType.GuildCategory,
ChannelType.GuildNews,
ChannelType.GuildStore,
ChannelType.GuildNewsThread,
ChannelType.GuildPublicThread,
ChannelType.GuildPrivateThread,
Expand Down
2 changes: 1 addition & 1 deletion packages/discord.js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 0 additions & 1 deletion packages/discord.js/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
10 changes: 0 additions & 10 deletions packages/discord.js/src/managers/GuildChannelManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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,
Expand Down
3 changes: 1 addition & 2 deletions packages/discord.js/src/managers/GuildInviteManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/

Expand Down
14 changes: 0 additions & 14 deletions packages/discord.js/src/structures/Channel.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ let CategoryChannel;
let DMChannel;
let NewsChannel;
let StageChannel;
let StoreChannel;
let TextChannel;
let ThreadChannel;
let VoiceChannel;
Expand Down Expand Up @@ -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}
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions packages/discord.js/src/structures/Guild.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/

Expand Down Expand Up @@ -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 =>
Expand Down
1 change: 0 additions & 1 deletion packages/discord.js/src/structures/GuildChannel.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ const PermissionsBitField = require('../util/PermissionsBitField');
* - {@link VoiceChannel}
* - {@link CategoryChannel}
* - {@link NewsChannel}
* - {@link StoreChannel}
* - {@link StageChannel}
* @extends {Channel}
* @abstract
Expand Down
56 changes: 0 additions & 56 deletions packages/discord.js/src/structures/StoreChannel.js

This file was deleted.

2 changes: 1 addition & 1 deletion packages/discord.js/src/structures/WelcomeChannel.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
41 changes: 5 additions & 36 deletions packages/discord.js/typings/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,6 @@ export interface MappedChannelCategoryTypes {
[ChannelType.GuildNews]: NewsChannel;
[ChannelType.GuildVoice]: VoiceChannel;
[ChannelType.GuildText]: TextChannel;
[ChannelType.GuildStore]: StoreChannel;
[ChannelType.GuildStageVoice]: StageChannel;
}

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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>;
}

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -4911,7 +4882,6 @@ export interface PartialChannelData {
| ChannelType.DM
| ChannelType.GroupDM
| ChannelType.GuildNews
| ChannelType.GuildStore
| ChannelType.GuildNewsThread
| ChannelType.GuildPublicThread
| ChannelType.GuildPrivateThread
Expand Down Expand Up @@ -5135,7 +5105,6 @@ export type AnyChannel =
| PartialGroupDMChannel
| NewsChannel
| StageChannel
| StoreChannel
| TextChannel
| ThreadChannel
| VoiceChannel;
Expand Down Expand Up @@ -5261,7 +5230,7 @@ export interface WidgetChannel {

export interface WelcomeChannelData {
description: string;
channel: TextChannel | NewsChannel | StoreChannel | Snowflake;
channel: GuildTextChannelResolvable;
emoji?: EmojiIdentifierResolvable;
}

Expand Down
16 changes: 3 additions & 13 deletions packages/discord.js/typings/index.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ import {
ShardingManager,
Snowflake,
StageChannel,
StoreChannel,
TextBasedChannelFields,
TextBasedChannel,
TextBasedChannelTypes,
Expand Down Expand Up @@ -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;
Expand All @@ -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');
Expand Down Expand Up @@ -996,23 +990,21 @@ 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'));
}

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<VoiceChannel>>(guildChannelManager.create('name', { type: ChannelType.GuildVoice }));
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());
Expand Down Expand Up @@ -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({
Expand Down