From f5ebb2088bdecaf468acdf2d06889a9ef8e93af7 Mon Sep 17 00:00:00 2001 From: Jiralite <33201955+Jiralite@users.noreply.github.com> Date: Tue, 19 Nov 2024 12:49:25 +0000 Subject: [PATCH] refactor(GatewayGuildCreateDispatchData): Narrow `channels` and `threads` types (#1146) * refactor: narrow guild create types * refactor: use `GuildChannelType` and `ThreadChannelType` --- deno/gateway/v10.ts | 6 ++++-- deno/gateway/v9.ts | 6 ++++-- gateway/v10.ts | 6 ++++-- gateway/v9.ts | 6 ++++-- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/deno/gateway/v10.ts b/deno/gateway/v10.ts index e9fdb86c..6a8b25b5 100644 --- a/deno/gateway/v10.ts +++ b/deno/gateway/v10.ts @@ -37,6 +37,8 @@ import type { ChannelType, APISubscription, APISoundboardSound, + GuildChannelType, + ThreadChannelType, } from '../payloads/v10/mod.ts'; import type { ReactionType } from '../rest/v10/mod.ts'; import type { Nullable } from '../utils/internals.ts'; @@ -879,7 +881,7 @@ export interface GatewayGuildCreateDispatchData extends APIGuild { * * See https://discord.com/developers/docs/resources/channel#channel-object */ - channels: APIChannel[]; + channels: (APIChannel & { type: Exclude })[]; /** * Threads in the guild * @@ -887,7 +889,7 @@ export interface GatewayGuildCreateDispatchData extends APIGuild { * * See https://discord.com/developers/docs/resources/channel#channel-object */ - threads: APIChannel[]; + threads: (APIChannel & { type: ThreadChannelType })[]; /** * Presences of the members in the guild, will only include non-offline members if the size is greater than `large_threshold` * diff --git a/deno/gateway/v9.ts b/deno/gateway/v9.ts index 53c6b0a3..ea91ecf0 100644 --- a/deno/gateway/v9.ts +++ b/deno/gateway/v9.ts @@ -36,6 +36,8 @@ import type { ChannelType, APISubscription, APISoundboardSound, + GuildChannelType, + ThreadChannelType, } from '../payloads/v9/mod.ts'; import type { ReactionType } from '../rest/v9/mod.ts'; import type { Nullable } from '../utils/internals.ts'; @@ -878,7 +880,7 @@ export interface GatewayGuildCreateDispatchData extends APIGuild { * * See https://discord.com/developers/docs/resources/channel#channel-object */ - channels: APIChannel[]; + channels: (APIChannel & { type: Exclude })[]; /** * Threads in the guild * @@ -886,7 +888,7 @@ export interface GatewayGuildCreateDispatchData extends APIGuild { * * See https://discord.com/developers/docs/resources/channel#channel-object */ - threads: APIChannel[]; + threads: (APIChannel & { type: ThreadChannelType })[]; /** * Presences of the members in the guild, will only include non-offline members if the size is greater than `large_threshold` * diff --git a/gateway/v10.ts b/gateway/v10.ts index 793d696f..c6ac200f 100644 --- a/gateway/v10.ts +++ b/gateway/v10.ts @@ -37,6 +37,8 @@ import type { ChannelType, APISubscription, APISoundboardSound, + GuildChannelType, + ThreadChannelType, } from '../payloads/v10/index'; import type { ReactionType } from '../rest/v10/index'; import type { Nullable } from '../utils/internals'; @@ -879,7 +881,7 @@ export interface GatewayGuildCreateDispatchData extends APIGuild { * * See https://discord.com/developers/docs/resources/channel#channel-object */ - channels: APIChannel[]; + channels: (APIChannel & { type: Exclude })[]; /** * Threads in the guild * @@ -887,7 +889,7 @@ export interface GatewayGuildCreateDispatchData extends APIGuild { * * See https://discord.com/developers/docs/resources/channel#channel-object */ - threads: APIChannel[]; + threads: (APIChannel & { type: ThreadChannelType })[]; /** * Presences of the members in the guild, will only include non-offline members if the size is greater than `large_threshold` * diff --git a/gateway/v9.ts b/gateway/v9.ts index a14410c8..c28bb18f 100644 --- a/gateway/v9.ts +++ b/gateway/v9.ts @@ -36,6 +36,8 @@ import type { ChannelType, APISubscription, APISoundboardSound, + GuildChannelType, + ThreadChannelType, } from '../payloads/v9/index'; import type { ReactionType } from '../rest/v9/index'; import type { Nullable } from '../utils/internals'; @@ -878,7 +880,7 @@ export interface GatewayGuildCreateDispatchData extends APIGuild { * * See https://discord.com/developers/docs/resources/channel#channel-object */ - channels: APIChannel[]; + channels: (APIChannel & { type: Exclude })[]; /** * Threads in the guild * @@ -886,7 +888,7 @@ export interface GatewayGuildCreateDispatchData extends APIGuild { * * See https://discord.com/developers/docs/resources/channel#channel-object */ - threads: APIChannel[]; + threads: (APIChannel & { type: ThreadChannelType })[]; /** * Presences of the members in the guild, will only include non-offline members if the size is greater than `large_threshold` *