Skip to content

Commit

Permalink
chore: update code
Browse files Browse the repository at this point in the history
  • Loading branch information
Jiralite committed Aug 23, 2023
1 parent 3450ad2 commit 5174e95
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ const allowedChannelTypes = [
ChannelType.PrivateThread,
ChannelType.GuildStageVoice,
ChannelType.GuildForum,
// @ts-expect-error: discord-api-types.
ChannelType.GuildMedia,
] as const;

Expand Down
3 changes: 1 addition & 2 deletions packages/discord.js/src/util/Channels.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ function createChannel(client, data, guild, { allowUnknownGuild } = {}) {
case ChannelType.GuildForum:
channel = new (getForumChannel())(guild, data, client);
break;
// TODO: ChannelType.GuildMedia
case 16:
case ChannelType.GuildMedia:
channel = new (getMediaChannel())(guild, data, client);
break;
}
Expand Down
12 changes: 8 additions & 4 deletions packages/discord.js/src/util/Util.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,13 @@ function makePlainError(err) {
};
}

// TODO: ChannelType.GuildMedia
const TextSortableGroupTypes = [ChannelType.GuildText, ChannelType.GuildAnnouncement, ChannelType.GuildForum, 16];
const TextSortableGroupTypes = [
ChannelType.GuildText,
ChannelType.GuildAnnouncement,
ChannelType.GuildForum,
ChannelType.GuildMedia,
];

const VoiceSortableGroupTypes = [ChannelType.GuildVoice, ChannelType.GuildStageVoice];
const CategorySortableGroupTypes = [ChannelType.GuildCategory];

Expand All @@ -182,8 +187,7 @@ function getSortableGroupTypes(type) {
case ChannelType.GuildText:
case ChannelType.GuildAnnouncement:
case ChannelType.GuildForum:
case 16:
// TODO: ChannelType.GuildMedia
case ChannelType.GuildMedia:
return TextSortableGroupTypes;
case ChannelType.GuildVoice:
case ChannelType.GuildStageVoice:
Expand Down
7 changes: 1 addition & 6 deletions packages/discord.js/typings/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -894,7 +894,6 @@ export interface MappedChannelCategoryTypes {
[ChannelType.GuildText]: TextChannel;
[ChannelType.GuildStageVoice]: StageChannel;
[ChannelType.GuildForum]: ForumChannel;
// @ts-expect-error discord-api-types.
[ChannelType.GuildMedia]: MediaChannel;
}

Expand All @@ -907,8 +906,6 @@ export type CategoryChannelType = Exclude<
| ChannelType.PrivateThread
| ChannelType.GuildCategory
| ChannelType.GuildDirectory
// TODO: https://github.com/discordjs/discord.js/pull/9662
| ChannelType.GuildMedia
>;

export class CategoryChannel extends GuildChannel {
Expand Down Expand Up @@ -2400,7 +2397,6 @@ export class ThreadOnlyChannel extends TextBasedChannelMixin(GuildChannel, true,
'createMessageComponentCollector',
'awaitMessageComponent',
]) {
// @ts-expect-error: discord-api-types.
public type: ChannelType.GuildForum | ChannelType.GuildMedia;
public threads: GuildForumThreadManager;
public availableTags: GuildForumTag[];
Expand Down Expand Up @@ -2430,8 +2426,7 @@ export class ForumChannel extends ThreadOnlyChannel {
public setDefaultForumLayout(defaultForumLayout: ForumLayoutType, reason?: string): Promise<this>;
}

export class MediaChannel extends ForumChannel {
// @ts-expect-error: discord-api-types.
export class MediaChannel extends ThreadOnlyChannel {
public type: ChannelType.GuildMedia;
}

Expand Down
6 changes: 1 addition & 5 deletions packages/discord.js/typings/index.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1539,7 +1539,6 @@ declare const guildChannelManager: GuildChannelManager;
expectType<Promise<NewsChannel>>(guildChannelManager.create({ name: 'name', type: ChannelType.GuildAnnouncement }));
expectType<Promise<StageChannel>>(guildChannelManager.create({ name: 'name', type: ChannelType.GuildStageVoice }));
expectType<Promise<ForumChannel>>(guildChannelManager.create({ name: 'name', type: ChannelType.GuildForum }));
// @ts-expect-error discord-api-types.
expectType<Promise<MediaChannel>>(guildChannelManager.create({ name: 'name', type: ChannelType.GuildMedia }));

expectType<Promise<Collection<Snowflake, NonThreadGuildBasedChannel | null>>>(guildChannelManager.fetch());
Expand Down Expand Up @@ -1923,10 +1922,7 @@ client.on('interactionCreate', async interaction => {
expectType<ForumChannel | VoiceChannel | null>(
interaction.options.getChannel('test', false, [ChannelType.GuildForum, ChannelType.GuildVoice]),
);
expectType<MediaChannel>(
// @ts-expect-error discord-api-types.
interaction.options.getChannel('test', true, [ChannelType.MediaChannel]),
);
expectType<MediaChannel>(interaction.options.getChannel('test', true, [ChannelType.GuildMedia]));
} else {
// @ts-expect-error
consumeCachedCommand(interaction);
Expand Down

0 comments on commit 5174e95

Please sign in to comment.