Skip to content

Commit d7d1044

Browse files
committed
refactor: add APISortableChannel
1 parent 58ebe46 commit d7d1044

File tree

5 files changed

+54
-31
lines changed

5 files changed

+54
-31
lines changed

deno/payloads/v10/channel.ts

Lines changed: 14 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

deno/payloads/v9/channel.ts

Lines changed: 13 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

payloads/v10/channel.ts

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,13 @@ export interface APITextBasedChannel<T extends ChannelType> extends APIChannelBa
9898
rate_limit_per_user?: number;
9999
}
100100

101+
export interface APISortableChannel {
102+
/**
103+
* Sorting position of the channel
104+
*/
105+
position: number;
106+
}
107+
101108
export interface APIGuildChannel<T extends ChannelType> extends Omit<APIChannelBase<T>, 'name'> {
102109
/**
103110
* The name of the channel (1-100 characters)
@@ -113,10 +120,6 @@ export interface APIGuildChannel<T extends ChannelType> extends Omit<APIChannelB
113120
* @see {@link https://discord.com/developers/docs/resources/channel#overwrite-object}
114121
*/
115122
permission_overwrites?: APIOverwrite[];
116-
/**
117-
* Sorting position of the channel
118-
*/
119-
position: number;
120123
/**
121124
* ID of the parent category for a channel (each parent category can contain up to 50 channels)
122125
*
@@ -135,7 +138,8 @@ export type GuildTextChannelType = Exclude<TextChannelType, ChannelType.DM | Cha
135138

136139
export interface APIGuildTextChannel<T extends ChannelType.GuildForum | ChannelType.GuildMedia | GuildTextChannelType>
137140
extends Omit<APITextBasedChannel<T>, 'name'>,
138-
APIGuildChannel<T> {
141+
APIGuildChannel<T>,
142+
APISortableChannel {
139143
/**
140144
* Default duration for newly created threads, in minutes, to automatically archive the thread after recent activity
141145
*/
@@ -153,10 +157,11 @@ export interface APIGuildTextChannel<T extends ChannelType.GuildForum | ChannelT
153157

154158
export type APITextChannel = APIGuildTextChannel<ChannelType.GuildText>;
155159
export type APINewsChannel = APIGuildTextChannel<ChannelType.GuildAnnouncement>;
156-
export type APIGuildCategoryChannel = APIGuildChannel<ChannelType.GuildCategory>;
160+
export interface APIGuildCategoryChannel extends APIGuildChannel<ChannelType.GuildCategory>, APISortableChannel {}
157161

158162
export interface APIVoiceChannelBase<T extends ChannelType>
159163
extends APIGuildChannel<T>,
164+
APISortableChannel,
160165
Omit<APITextBasedChannel<T>, 'last_pin_timestamp' | 'name'> {
161166
/**
162167
* The bitrate (in bits) of the voice or stage channel
@@ -231,7 +236,7 @@ export type ThreadChannelType = ChannelType.AnnouncementThread | ChannelType.Pri
231236

232237
export interface APIThreadChannel<Type extends ThreadChannelType = ThreadChannelType>
233238
extends Omit<APITextBasedChannel<Type>, 'name'>,
234-
Omit<APIGuildChannel<Type>, 'position'> {
239+
APIGuildChannel<Type> {
235240
/**
236241
* The client users member for the thread, only included in select endpoints
237242
*/
@@ -343,7 +348,8 @@ export enum ForumLayoutType {
343348
}
344349

345350
export interface APIThreadOnlyChannel<T extends ChannelType.GuildForum | ChannelType.GuildMedia>
346-
extends APIGuildChannel<T> {
351+
extends APIGuildChannel<T>,
352+
APISortableChannel {
347353
/**
348354
* The channel topic (0-4096 characters)
349355
*/

payloads/v9/channel.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,13 @@ export interface APITextBasedChannel<T extends ChannelType> extends APIChannelBa
9898
rate_limit_per_user?: number;
9999
}
100100

101+
export interface APISortableChannel {
102+
/**
103+
* Sorting position of the channel
104+
*/
105+
position: number;
106+
}
107+
101108
export interface APIGuildChannel<T extends ChannelType> extends Omit<APIChannelBase<T>, 'name'> {
102109
/**
103110
* The name of the channel (1-100 characters)
@@ -113,10 +120,6 @@ export interface APIGuildChannel<T extends ChannelType> extends Omit<APIChannelB
113120
* @see {@link https://discord.com/developers/docs/resources/channel#overwrite-object}
114121
*/
115122
permission_overwrites?: APIOverwrite[];
116-
/**
117-
* Sorting position of the channel
118-
*/
119-
position: number;
120123
/**
121124
* ID of the parent category for a channel (each parent category can contain up to 50 channels)
122125
*
@@ -135,6 +138,7 @@ export type GuildTextChannelType = Exclude<TextChannelType, ChannelType.DM | Cha
135138

136139
export interface APIGuildTextChannel<T extends ChannelType.GuildForum | ChannelType.GuildMedia | GuildTextChannelType>
137140
extends Omit<APITextBasedChannel<T>, 'name'>,
141+
APISortableChannel,
138142
APIGuildChannel<T> {
139143
/**
140144
* Default duration for newly created threads, in minutes, to automatically archive the thread after recent activity
@@ -153,10 +157,11 @@ export interface APIGuildTextChannel<T extends ChannelType.GuildForum | ChannelT
153157

154158
export type APITextChannel = APIGuildTextChannel<ChannelType.GuildText>;
155159
export type APINewsChannel = APIGuildTextChannel<ChannelType.GuildAnnouncement>;
156-
export type APIGuildCategoryChannel = APIGuildChannel<ChannelType.GuildCategory>;
160+
export interface APIGuildCategoryChannel extends APIGuildChannel<ChannelType.GuildCategory>, APISortableChannel {}
157161

158162
export interface APIVoiceChannelBase<T extends ChannelType>
159163
extends APIGuildChannel<T>,
164+
APISortableChannel,
160165
Omit<APITextBasedChannel<T>, 'last_pin_timestamp' | 'name'> {
161166
/**
162167
* The bitrate (in bits) of the voice or stage channel
@@ -231,7 +236,7 @@ export type ThreadChannelType = ChannelType.AnnouncementThread | ChannelType.Pri
231236

232237
export interface APIThreadChannel<Type extends ThreadChannelType = ThreadChannelType>
233238
extends Omit<APITextBasedChannel<Type>, 'name'>,
234-
Omit<APIGuildChannel<Type>, 'position'> {
239+
APIGuildChannel<Type> {
235240
/**
236241
* The client users member for the thread, only included in select endpoints
237242
*/
@@ -343,7 +348,8 @@ export enum ForumLayoutType {
343348
}
344349

345350
export interface APIThreadOnlyChannel<T extends ChannelType.GuildForum | ChannelType.GuildMedia>
346-
extends APIGuildChannel<T> {
351+
extends APIGuildChannel<T>,
352+
APISortableChannel {
347353
/**
348354
* The channel topic (0-4096 characters)
349355
*/

tests/v10/channel.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ expectNotAssignable<AnyGuildChannel>(dmChannel);
2828
// @ts-expect-error - groupDMChannel is not assignable to AnyGuildChannel
2929
expectNotAssignable<AnyGuildChannel>(groupDMChannel);
3030
expectAssignable<AnyGuildChannel>(guildTextChannel);
31-
// @ts-expect-error - guildThreadChannel is not assignable to AnyGuildChannel
3231
expectAssignable<AnyGuildChannel>(guildThreadChannel);
3332
expectAssignable<AnyGuildChannel>(guildVoiceChannel);
3433
expectAssignable<AnyGuildChannel>(guildVoiceStageChannel);

0 commit comments

Comments
 (0)