From 72b8c830ee6ed369085644e93b3e27849b0274ed Mon Sep 17 00:00:00 2001 From: Qjuh <76154676+Qjuh@users.noreply.github.com> Date: Sun, 25 May 2025 13:47:12 +0200 Subject: [PATCH] fix: discriminated thread channel types (#1247) --- deno/payloads/v10/channel.ts | 36 ++++++++++++++++++++++++------------ deno/payloads/v9/auditLog.ts | 2 +- deno/payloads/v9/channel.ts | 34 +++++++++++++++++++++++----------- payloads/v10/channel.ts | 36 ++++++++++++++++++++++++------------ payloads/v9/auditLog.ts | 2 +- payloads/v9/channel.ts | 34 +++++++++++++++++++++++----------- 6 files changed, 96 insertions(+), 48 deletions(-) diff --git a/deno/payloads/v10/channel.ts b/deno/payloads/v10/channel.ts index 2452ebbe..617b1798 100644 --- a/deno/payloads/v10/channel.ts +++ b/deno/payloads/v10/channel.ts @@ -98,6 +98,13 @@ export interface APITextBasedChannel extends APIChannelBa rate_limit_per_user?: number; } +export interface APISortableChannel { + /** + * Sorting position of the channel + */ + position: number; +} + export interface APIGuildChannel extends Omit, 'name'> { /** * The name of the channel (1-100 characters) @@ -113,10 +120,6 @@ export interface APIGuildChannel extends Omit extends Omit, 'name'>, - APIGuildChannel { + APIGuildChannel, + APISortableChannel { /** * Default duration for newly created threads, in minutes, to automatically archive the thread after recent activity */ @@ -153,10 +157,11 @@ export interface APIGuildTextChannel; export type APINewsChannel = APIGuildTextChannel; -export type APIGuildCategoryChannel = APIGuildChannel; +export interface APIGuildCategoryChannel extends APIGuildChannel, APISortableChannel {} export interface APIVoiceChannelBase extends APIGuildChannel, + APISortableChannel, Omit, 'last_pin_timestamp' | 'name'> { /** * The bitrate (in bits) of the voice or stage channel @@ -229,9 +234,9 @@ export interface APIGroupDMChannel extends Omit, 'name'>, - APIGuildChannel { +export interface APIThreadChannel + extends Omit, 'name'>, + APIGuildChannel { /** * The client users member for the thread, only included in select endpoints */ @@ -266,6 +271,10 @@ export interface APIThreadChannel applied_tags: Snowflake[]; } +export type APIPublicThreadChannel = APIThreadChannel; +export type APIPrivateThreadChannel = APIThreadChannel; +export type APIAnnouncementThreadChannel = APIThreadChannel; + /** * @see {@link https://discord.com/developers/docs/resources/channel#forum-tag-object-forum-tag-structure} */ @@ -339,7 +348,8 @@ export enum ForumLayoutType { } export interface APIThreadOnlyChannel - extends APIGuildChannel { + extends APIGuildChannel, + APISortableChannel { /** * The channel topic (0-4096 characters) */ @@ -398,6 +408,7 @@ export type APIGuildMediaChannel = APIThreadOnlyChannel; * @see {@link https://discord.com/developers/docs/resources/channel#channel-object-channel-structure} */ export type APIChannel = + | APIAnnouncementThreadChannel | APIDMChannel | APIGroupDMChannel | APIGuildCategoryChannel @@ -406,8 +417,9 @@ export type APIChannel = | APIGuildStageVoiceChannel | APIGuildVoiceChannel | APINewsChannel - | APITextChannel - | APIThreadChannel; + | APIPrivateThreadChannel + | APIPublicThreadChannel + | APITextChannel; /** * @see {@link https://discord.com/developers/docs/resources/channel#channel-object-channel-types} diff --git a/deno/payloads/v9/auditLog.ts b/deno/payloads/v9/auditLog.ts index 6e27ad34..11d6d579 100644 --- a/deno/payloads/v9/auditLog.ts +++ b/deno/payloads/v9/auditLog.ts @@ -325,7 +325,7 @@ export interface APIAuditLogOptions { * - CHANNEL_OVERWRITE_UPDATE * - CHANNEL_OVERWRITE_DELETE * - * **Present only if the {@link APIAuditLogOptions.type | entry type} is "0"** + * **Present only if the {@link APIAuditLogOptions."type" | entry type} is "0"** */ role_name?: string; diff --git a/deno/payloads/v9/channel.ts b/deno/payloads/v9/channel.ts index 46ae5e82..508ce0c2 100644 --- a/deno/payloads/v9/channel.ts +++ b/deno/payloads/v9/channel.ts @@ -98,6 +98,13 @@ export interface APITextBasedChannel extends APIChannelBa rate_limit_per_user?: number; } +export interface APISortableChannel { + /** + * Sorting position of the channel + */ + position: number; +} + export interface APIGuildChannel extends Omit, 'name'> { /** * The name of the channel (1-100 characters) @@ -113,10 +120,6 @@ export interface APIGuildChannel extends Omit extends Omit, 'name'>, + APISortableChannel, APIGuildChannel { /** * Default duration for newly created threads, in minutes, to automatically archive the thread after recent activity @@ -153,10 +157,11 @@ export interface APIGuildTextChannel; export type APINewsChannel = APIGuildTextChannel; -export type APIGuildCategoryChannel = APIGuildChannel; +export interface APIGuildCategoryChannel extends APIGuildChannel, APISortableChannel {} export interface APIVoiceChannelBase extends APIGuildChannel, + APISortableChannel, Omit, 'last_pin_timestamp' | 'name'> { /** * The bitrate (in bits) of the voice or stage channel @@ -229,9 +234,9 @@ export interface APIGroupDMChannel extends Omit, 'name'>, - APIGuildChannel { +export interface APIThreadChannel + extends Omit, 'name'>, + APIGuildChannel { /** * The client users member for the thread, only included in select endpoints */ @@ -266,6 +271,10 @@ export interface APIThreadChannel applied_tags: Snowflake[]; } +export type APIPublicThreadChannel = APIThreadChannel; +export type APIPrivateThreadChannel = APIThreadChannel; +export type APIAnnouncementThreadChannel = APIThreadChannel; + /** * @see {@link https://discord.com/developers/docs/resources/channel#forum-tag-object-forum-tag-structure} */ @@ -339,7 +348,8 @@ export enum ForumLayoutType { } export interface APIThreadOnlyChannel - extends APIGuildChannel { + extends APIGuildChannel, + APISortableChannel { /** * The channel topic (0-4096 characters) */ @@ -398,6 +408,7 @@ export type APIGuildMediaChannel = APIThreadOnlyChannel; * @see {@link https://discord.com/developers/docs/resources/channel#channel-object-channel-structure} */ export type APIChannel = + | APIAnnouncementThreadChannel | APIDMChannel | APIGroupDMChannel | APIGuildCategoryChannel @@ -406,8 +417,9 @@ export type APIChannel = | APIGuildStageVoiceChannel | APIGuildVoiceChannel | APINewsChannel - | APITextChannel - | APIThreadChannel; + | APIPrivateThreadChannel + | APIPublicThreadChannel + | APITextChannel; /** * @see {@link https://discord.com/developers/docs/resources/channel#channel-object-channel-types} diff --git a/payloads/v10/channel.ts b/payloads/v10/channel.ts index 5ffce249..c5c6d45b 100644 --- a/payloads/v10/channel.ts +++ b/payloads/v10/channel.ts @@ -98,6 +98,13 @@ export interface APITextBasedChannel extends APIChannelBa rate_limit_per_user?: number; } +export interface APISortableChannel { + /** + * Sorting position of the channel + */ + position: number; +} + export interface APIGuildChannel extends Omit, 'name'> { /** * The name of the channel (1-100 characters) @@ -113,10 +120,6 @@ export interface APIGuildChannel extends Omit extends Omit, 'name'>, - APIGuildChannel { + APIGuildChannel, + APISortableChannel { /** * Default duration for newly created threads, in minutes, to automatically archive the thread after recent activity */ @@ -153,10 +157,11 @@ export interface APIGuildTextChannel; export type APINewsChannel = APIGuildTextChannel; -export type APIGuildCategoryChannel = APIGuildChannel; +export interface APIGuildCategoryChannel extends APIGuildChannel, APISortableChannel {} export interface APIVoiceChannelBase extends APIGuildChannel, + APISortableChannel, Omit, 'last_pin_timestamp' | 'name'> { /** * The bitrate (in bits) of the voice or stage channel @@ -229,9 +234,9 @@ export interface APIGroupDMChannel extends Omit, 'name'>, - APIGuildChannel { +export interface APIThreadChannel + extends Omit, 'name'>, + APIGuildChannel { /** * The client users member for the thread, only included in select endpoints */ @@ -266,6 +271,10 @@ export interface APIThreadChannel applied_tags: Snowflake[]; } +export type APIPublicThreadChannel = APIThreadChannel; +export type APIPrivateThreadChannel = APIThreadChannel; +export type APIAnnouncementThreadChannel = APIThreadChannel; + /** * @see {@link https://discord.com/developers/docs/resources/channel#forum-tag-object-forum-tag-structure} */ @@ -339,7 +348,8 @@ export enum ForumLayoutType { } export interface APIThreadOnlyChannel - extends APIGuildChannel { + extends APIGuildChannel, + APISortableChannel { /** * The channel topic (0-4096 characters) */ @@ -398,6 +408,7 @@ export type APIGuildMediaChannel = APIThreadOnlyChannel; * @see {@link https://discord.com/developers/docs/resources/channel#channel-object-channel-structure} */ export type APIChannel = + | APIAnnouncementThreadChannel | APIDMChannel | APIGroupDMChannel | APIGuildCategoryChannel @@ -406,8 +417,9 @@ export type APIChannel = | APIGuildStageVoiceChannel | APIGuildVoiceChannel | APINewsChannel - | APITextChannel - | APIThreadChannel; + | APIPrivateThreadChannel + | APIPublicThreadChannel + | APITextChannel; /** * @see {@link https://discord.com/developers/docs/resources/channel#channel-object-channel-types} diff --git a/payloads/v9/auditLog.ts b/payloads/v9/auditLog.ts index 55b7d2f3..c330c757 100644 --- a/payloads/v9/auditLog.ts +++ b/payloads/v9/auditLog.ts @@ -325,7 +325,7 @@ export interface APIAuditLogOptions { * - CHANNEL_OVERWRITE_UPDATE * - CHANNEL_OVERWRITE_DELETE * - * **Present only if the {@link APIAuditLogOptions.type | entry type} is "0"** + * **Present only if the {@link APIAuditLogOptions."type" | entry type} is "0"** */ role_name?: string; diff --git a/payloads/v9/channel.ts b/payloads/v9/channel.ts index 2e1d5a6a..b47bfa64 100644 --- a/payloads/v9/channel.ts +++ b/payloads/v9/channel.ts @@ -98,6 +98,13 @@ export interface APITextBasedChannel extends APIChannelBa rate_limit_per_user?: number; } +export interface APISortableChannel { + /** + * Sorting position of the channel + */ + position: number; +} + export interface APIGuildChannel extends Omit, 'name'> { /** * The name of the channel (1-100 characters) @@ -113,10 +120,6 @@ export interface APIGuildChannel extends Omit extends Omit, 'name'>, + APISortableChannel, APIGuildChannel { /** * Default duration for newly created threads, in minutes, to automatically archive the thread after recent activity @@ -153,10 +157,11 @@ export interface APIGuildTextChannel; export type APINewsChannel = APIGuildTextChannel; -export type APIGuildCategoryChannel = APIGuildChannel; +export interface APIGuildCategoryChannel extends APIGuildChannel, APISortableChannel {} export interface APIVoiceChannelBase extends APIGuildChannel, + APISortableChannel, Omit, 'last_pin_timestamp' | 'name'> { /** * The bitrate (in bits) of the voice or stage channel @@ -229,9 +234,9 @@ export interface APIGroupDMChannel extends Omit, 'name'>, - APIGuildChannel { +export interface APIThreadChannel + extends Omit, 'name'>, + APIGuildChannel { /** * The client users member for the thread, only included in select endpoints */ @@ -266,6 +271,10 @@ export interface APIThreadChannel applied_tags: Snowflake[]; } +export type APIPublicThreadChannel = APIThreadChannel; +export type APIPrivateThreadChannel = APIThreadChannel; +export type APIAnnouncementThreadChannel = APIThreadChannel; + /** * @see {@link https://discord.com/developers/docs/resources/channel#forum-tag-object-forum-tag-structure} */ @@ -339,7 +348,8 @@ export enum ForumLayoutType { } export interface APIThreadOnlyChannel - extends APIGuildChannel { + extends APIGuildChannel, + APISortableChannel { /** * The channel topic (0-4096 characters) */ @@ -398,6 +408,7 @@ export type APIGuildMediaChannel = APIThreadOnlyChannel; * @see {@link https://discord.com/developers/docs/resources/channel#channel-object-channel-structure} */ export type APIChannel = + | APIAnnouncementThreadChannel | APIDMChannel | APIGroupDMChannel | APIGuildCategoryChannel @@ -406,8 +417,9 @@ export type APIChannel = | APIGuildStageVoiceChannel | APIGuildVoiceChannel | APINewsChannel - | APITextChannel - | APIThreadChannel; + | APIPrivateThreadChannel + | APIPublicThreadChannel + | APITextChannel; /** * @see {@link https://discord.com/developers/docs/resources/channel#channel-object-channel-types}