From 19e74b153317cf8b910317c56beb95a698acc00c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?T=C3=86MB=C3=98?= <69138346+TAEMBO@users.noreply.github.com> Date: Wed, 2 Jul 2025 15:21:13 -0700 Subject: [PATCH] types(InteractionCallbackResponse): add missing InGuild generic (#10963) --- packages/discord.js/typings/index.d.ts | 68 +++++++++++------ packages/discord.js/typings/index.test-d.ts | 82 ++++++++++----------- 2 files changed, 86 insertions(+), 64 deletions(-) diff --git a/packages/discord.js/typings/index.d.ts b/packages/discord.js/typings/index.d.ts index 8497f8c01..1ce6d65eb 100644 --- a/packages/discord.js/typings/index.d.ts +++ b/packages/discord.js/typings/index.d.ts @@ -599,7 +599,7 @@ export abstract class CommandInteraction e public inRawGuild(): this is CommandInteraction<'raw'>; public deferReply( options: InteractionDeferReplyOptions & { withResponse: true }, - ): Promise; + ): Promise>>; /** @deprecated `fetchReply` is deprecated. Use `withResponse` instead or fetch the response after using the method. */ public deferReply( options: InteractionDeferReplyOptions & { fetchReply: true }, @@ -611,29 +611,35 @@ export abstract class CommandInteraction e ): Promise>>; public fetchReply(message?: Snowflake | '@original'): Promise>>; public followUp(options: string | MessagePayload | InteractionReplyOptions): Promise>>; - public reply(options: InteractionReplyOptions & { withResponse: true }): Promise; + public reply( + options: InteractionReplyOptions & { withResponse: true }, + ): Promise>>; /** @deprecated `fetchReply` is deprecated. Use `withResponse` instead or fetch the response after using the method. */ public reply(options: InteractionReplyOptions & { fetchReply: true }): Promise>>; public reply( options: string | MessagePayload | InteractionReplyOptions, ): Promise>>; - public launchActivity(options: LaunchActivityOptions & { withResponse: true }): Promise; + public launchActivity( + options: LaunchActivityOptions & { withResponse: true }, + ): Promise>>; public launchActivity(options?: LaunchActivityOptions & { withResponse?: false }): Promise; - public launchActivity(options?: LaunchActivityOptions): Promise; + public launchActivity( + options?: LaunchActivityOptions, + ): Promise> | undefined>; public showModal( modal: | JSONEncodable | ModalComponentData | APIModalInteractionResponseCallbackData, options: ShowModalOptions & { withResponse: true }, - ): Promise; + ): Promise>>; public showModal( modal: | JSONEncodable | ModalComponentData | APIModalInteractionResponseCallbackData, options?: ShowModalOptions & { withResponse: true }, - ): Promise; + ): Promise>>; public showModal( modal: | JSONEncodable @@ -2159,17 +2165,17 @@ export class InteractionCallback { public type: InteractionType; } -export class InteractionCallbackResponse { +export class InteractionCallbackResponse { private constructor(client: Client, data: RESTPostAPIInteractionCallbackWithResponseResult); public readonly client: Client; public interaction: InteractionCallback; - public resource: InteractionCallbackResource | null; + public resource: InteractionCallbackResource | null; } -export class InteractionCallbackResource { +export class InteractionCallbackResource { private constructor(client: Client, data: RESTAPIInteractionCallbackResourceObject); public activityInstance: RESTAPIInteractionCallbackActivityInstanceResource | null; - public message: Message | null; + public message: Message | null; public type: InteractionResponseType; } @@ -2526,7 +2532,7 @@ export class MessageComponentInteraction e public inRawGuild(): this is MessageComponentInteraction<'raw'>; public deferReply( options: InteractionDeferReplyOptions & { withResponse: true }, - ): Promise; + ): Promise>>; /** @deprecated `fetchReply` is deprecated. Use `withResponse` instead or fetch the response after using the method. */ public deferReply( options: InteractionDeferReplyOptions & { fetchReply: true }, @@ -2534,7 +2540,7 @@ export class MessageComponentInteraction e public deferReply(options?: InteractionDeferReplyOptions): Promise>>; public deferUpdate( options: InteractionDeferUpdateOptions & { withResponse: true }, - ): Promise; + ): Promise>>; /** @deprecated `fetchReply` is deprecated. Use `withResponse` instead or fetch the response after using the method. */ public deferUpdate( options: InteractionDeferUpdateOptions & { fetchReply: true }, @@ -2546,28 +2552,36 @@ export class MessageComponentInteraction e ): Promise>>; public fetchReply(message?: Snowflake | '@original'): Promise>>; public followUp(options: string | MessagePayload | InteractionReplyOptions): Promise>>; - public reply(options: InteractionReplyOptions & { withResponse: true }): Promise; + public reply( + options: InteractionReplyOptions & { withResponse: true }, + ): Promise>>; /** @deprecated `fetchReply` is deprecated. Use `withResponse` instead or fetch the response after using the method. */ public reply(options: InteractionReplyOptions & { fetchReply: true }): Promise>>; public reply( options: string | MessagePayload | InteractionReplyOptions, ): Promise>>; - public update(options: InteractionUpdateOptions & { withResponse: true }): Promise; + public update( + options: InteractionUpdateOptions & { withResponse: true }, + ): Promise>>; /** @deprecated `fetchReply` is deprecated. Use `withResponse` instead or fetch the response after using the method. */ public update(options: InteractionUpdateOptions & { fetchReply: true }): Promise>>; public update( options: string | MessagePayload | InteractionUpdateOptions, ): Promise>>; - public launchActivity(options: LaunchActivityOptions & { withResponse: true }): Promise; + public launchActivity( + options: LaunchActivityOptions & { withResponse: true }, + ): Promise>>; public launchActivity(options?: LaunchActivityOptions & { withResponse?: false }): Promise; - public launchActivity(options?: LaunchActivityOptions): Promise; + public launchActivity( + options?: LaunchActivityOptions, + ): Promise> | undefined>; public showModal( modal: | JSONEncodable | ModalComponentData | APIModalInteractionResponseCallbackData, options: ShowModalOptions & { withResponse: true }, - ): Promise; + ): Promise>>; public showModal( modal: | JSONEncodable @@ -2755,7 +2769,9 @@ export interface ModalMessageModalSubmitInteraction { message: Message>; channelId: Snowflake; - update(options: InteractionUpdateOptions & { withResponse: true }): Promise; + update( + options: InteractionUpdateOptions & { withResponse: true }, + ): Promise>>; /** @deprecated `fetchReply` is deprecated. Use `withResponse` instead or fetch the response after using the method. */ update(options: InteractionUpdateOptions & { fetchReply: true }): Promise; update( @@ -2777,7 +2793,9 @@ export class ModalSubmitInteraction extend public message: Message> | null; public replied: boolean; public readonly webhook: InteractionWebhook; - public reply(options: InteractionReplyOptions & { withResponse: true }): Promise; + public reply( + options: InteractionReplyOptions & { withResponse: true }, + ): Promise>>; /** @deprecated `fetchReply` is deprecated. Use `withResponse` instead or fetch the response after using the method. */ public reply(options: InteractionReplyOptions & { fetchReply: true }): Promise>>; public reply( @@ -2789,7 +2807,7 @@ export class ModalSubmitInteraction extend ): Promise>>; public deferReply( options: InteractionDeferReplyOptions & { withResponse: true }, - ): Promise; + ): Promise>>; /** @deprecated `fetchReply` is deprecated. Use `withResponse` instead or fetch the response after using the method. */ public deferReply( options: InteractionDeferReplyOptions & { fetchReply: true }, @@ -2799,7 +2817,7 @@ export class ModalSubmitInteraction extend public followUp(options: string | MessagePayload | InteractionReplyOptions): Promise>>; public deferUpdate( options: InteractionDeferUpdateOptions & { withResponse: true }, - ): Promise; + ): Promise>>; /** @deprecated `fetchReply` is deprecated. Use `withResponse` instead or fetch the response after using the method. */ public deferUpdate( options: InteractionDeferUpdateOptions & { fetchReply: true }, @@ -2807,9 +2825,13 @@ export class ModalSubmitInteraction extend public deferUpdate(options?: InteractionDeferUpdateOptions): Promise>>; /** @deprecated Sending a premium-style button is the new Discord behaviour. */ public sendPremiumRequired(): Promise; - public launchActivity(options: LaunchActivityOptions & { withResponse: true }): Promise; + public launchActivity( + options: LaunchActivityOptions & { withResponse: true }, + ): Promise>>; public launchActivity(options?: LaunchActivityOptions & { withResponse?: false }): Promise; - public launchActivity(options?: LaunchActivityOptions): Promise; + public launchActivity( + options?: LaunchActivityOptions, + ): Promise> | undefined>; public inGuild(): this is ModalSubmitInteraction<'raw' | 'cached'>; public inCachedGuild(): this is ModalSubmitInteraction<'cached'>; public inRawGuild(): this is ModalSubmitInteraction<'raw'>; diff --git a/packages/discord.js/typings/index.test-d.ts b/packages/discord.js/typings/index.test-d.ts index 8e9520503..2316cb088 100644 --- a/packages/discord.js/typings/index.test-d.ts +++ b/packages/discord.js/typings/index.test-d.ts @@ -463,7 +463,7 @@ client.on('messageCreate', async message => { const component = await message.awaitMessageComponent({ componentType: ComponentType.Button }); expectType>(component); expectType>(await component.reply({ fetchReply: true })); - expectType(await component.reply({ withResponse: true })); + expectType>(await component.reply({ withResponse: true })); const buttonCollector = message.createMessageComponentCollector({ componentType: ComponentType.Button }); expectType>>(buttonCollector); @@ -1882,18 +1882,18 @@ client.on('interactionCreate', async interaction => { expectType(interaction.guild); expectType>>(interaction.reply({ content: 'a', fetchReply: true })); expectType>>(interaction.deferReply({ fetchReply: true })); - expectType>(interaction.reply({ content: 'a', withResponse: true })); - expectType>(interaction.deferReply({ withResponse: true })); + expectType>>(interaction.reply({ content: 'a', withResponse: true })); + expectType>>(interaction.deferReply({ withResponse: true })); expectType>>(interaction.editReply({ content: 'a' })); expectType>>(interaction.fetchReply()); expectType>>(interaction.update({ content: 'a', fetchReply: true })); expectType>>(interaction.deferUpdate({ fetchReply: true })); - expectType>(interaction.update({ content: 'a', withResponse: true })); - expectType>(interaction.deferUpdate({ withResponse: true })); + expectType>>(interaction.update({ content: 'a', withResponse: true })); + expectType>>(interaction.deferUpdate({ withResponse: true })); expectType>>(interaction.followUp({ content: 'a' })); - expectType>(interaction.launchActivity({ withResponse: true })); + expectType>>(interaction.launchActivity({ withResponse: true })); expectType>(interaction.launchActivity({ withResponse: false })); - expectType>( + expectType | undefined>>( interaction.launchActivity({ withResponse: booleanValue }), ); } else if (interaction.inRawGuild()) { @@ -1903,18 +1903,18 @@ client.on('interactionCreate', async interaction => { expectType(interaction.guild); expectType>>(interaction.reply({ content: 'a', fetchReply: true })); expectType>>(interaction.deferReply({ fetchReply: true })); - expectType>(interaction.reply({ content: 'a', withResponse: true })); - expectType>(interaction.deferReply({ withResponse: true })); + expectType>>(interaction.reply({ content: 'a', withResponse: true })); + expectType>>(interaction.deferReply({ withResponse: true })); expectType>>(interaction.editReply({ content: 'a' })); expectType>>(interaction.fetchReply()); expectType>>(interaction.update({ content: 'a', fetchReply: true })); expectType>>(interaction.deferUpdate({ fetchReply: true })); - expectType>(interaction.update({ content: 'a', withResponse: true })); - expectType>(interaction.deferUpdate({ withResponse: true })); + expectType>>(interaction.update({ content: 'a', withResponse: true })); + expectType>>(interaction.deferUpdate({ withResponse: true })); expectType>>(interaction.followUp({ content: 'a' })); - expectType>(interaction.launchActivity({ withResponse: true })); + expectType>>(interaction.launchActivity({ withResponse: true })); expectType>(interaction.launchActivity({ withResponse: false })); - expectType>( + expectType | undefined>>( interaction.launchActivity({ withResponse: booleanValue }), ); } else if (interaction.inGuild()) { @@ -1972,14 +1972,14 @@ client.on('interactionCreate', async interaction => { expectAssignable>(interaction); expectType>>(interaction.reply({ content: 'a', fetchReply: true })); expectType>>(interaction.deferReply({ fetchReply: true })); - expectType>(interaction.reply({ content: 'a', withResponse: true })); - expectType>(interaction.deferReply({ withResponse: true })); + expectType>>(interaction.reply({ content: 'a', withResponse: true })); + expectType>>(interaction.deferReply({ withResponse: true })); expectType>>(interaction.editReply({ content: 'a' })); expectType>>(interaction.fetchReply()); expectType>>(interaction.followUp({ content: 'a' })); - expectType>(interaction.launchActivity({ withResponse: true })); + expectType>>(interaction.launchActivity({ withResponse: true })); expectType>(interaction.launchActivity({ withResponse: false })); - expectType>( + expectType | undefined>>( interaction.launchActivity({ withResponse: booleanValue }), ); } else if (interaction.inRawGuild()) { @@ -1987,14 +1987,14 @@ client.on('interactionCreate', async interaction => { expectType(interaction.guild); expectType>>(interaction.reply({ content: 'a', fetchReply: true })); expectType>>(interaction.deferReply({ fetchReply: true })); - expectType>(interaction.reply({ content: 'a', withResponse: true })); - expectType>(interaction.deferReply({ withResponse: true })); + expectType>>(interaction.reply({ content: 'a', withResponse: true })); + expectType>>(interaction.deferReply({ withResponse: true })); expectType>>(interaction.editReply({ content: 'a' })); expectType>>(interaction.fetchReply()); expectType>>(interaction.followUp({ content: 'a' })); - expectType>(interaction.launchActivity({ withResponse: true })); + expectType>>(interaction.launchActivity({ withResponse: true })); expectType>(interaction.launchActivity({ withResponse: false })); - expectType>( + expectType | undefined>>( interaction.launchActivity({ withResponse: booleanValue }), ); } else if (interaction.inGuild()) { @@ -2063,14 +2063,14 @@ client.on('interactionCreate', async interaction => { expectType>(interaction.message); expectType(interaction.guild); expectType>>(interaction.reply({ fetchReply: true })); - expectType>(interaction.reply({ withResponse: true })); + expectType>>(interaction.reply({ withResponse: true })); } else if (interaction.inRawGuild()) { expectAssignable(interaction); expectType(interaction.component); expectType>(interaction.message); expectType(interaction.guild); expectType>>(interaction.reply({ fetchReply: true })); - expectType>(interaction.reply({ withResponse: true })); + expectType>>(interaction.reply({ withResponse: true })); } else if (interaction.inGuild()) { expectAssignable(interaction); expectType(interaction.component); @@ -2094,14 +2094,14 @@ client.on('interactionCreate', async interaction => { expectType>(interaction.message); expectType(interaction.guild); expectType>>(interaction.reply({ fetchReply: true })); - expectType>(interaction.reply({ withResponse: true })); + expectType>>(interaction.reply({ withResponse: true })); } else if (interaction.inRawGuild()) { expectAssignable(interaction); expectType(interaction.component); expectType>(interaction.message); expectType(interaction.guild); expectType>>(interaction.reply({ fetchReply: true })); - expectType>(interaction.reply({ withResponse: true })); + expectType>>(interaction.reply({ withResponse: true })); } else if (interaction.inGuild()) { expectAssignable(interaction); expectType(interaction.component); @@ -2121,7 +2121,7 @@ client.on('interactionCreate', async interaction => { expectNotAssignable>(interaction); expectAssignable(interaction); expectType>>(interaction.reply({ fetchReply: true })); - expectType>(interaction.reply({ withResponse: true })); + expectType>>(interaction.reply({ withResponse: true })); expectType(interaction.options.getMember('test')); expectType(interaction.options.getChannel('test', true)); @@ -2136,7 +2136,7 @@ client.on('interactionCreate', async interaction => { expectType(interaction.options.getMember('test')); expectAssignable(interaction); expectType>>(interaction.reply({ fetchReply: true })); - expectType>(interaction.reply({ withResponse: true })); + expectType>>(interaction.reply({ withResponse: true })); expectType(interaction.options.getChannel('test', true)); expectType(interaction.options.getRole('test', true)); @@ -2208,28 +2208,28 @@ client.on('interactionCreate', async interaction => { expectAssignable(interaction); expectAssignable(interaction.guild); expectAssignable>(interaction); - expectType>(interaction.reply({ content: 'a', withResponse: true })); - expectType>(interaction.deferReply({ withResponse: true })); + expectType>>(interaction.reply({ content: 'a', withResponse: true })); + expectType>>(interaction.deferReply({ withResponse: true })); expectType>>(interaction.deferReply()); expectType>>(interaction.reply({ content: 'a', withResponse: false })); expectType>>(interaction.deferReply({ withResponse: false })); expectType>>(interaction.editReply({ content: 'a' })); expectType>>(interaction.fetchReply()); expectType>>(interaction.followUp({ content: 'a' })); - expectType>(interaction.launchActivity({ withResponse: true })); + expectType>>(interaction.launchActivity({ withResponse: true })); expectType>(interaction.launchActivity({ withResponse: false })); } else if (interaction.inRawGuild()) { expectAssignable(interaction); expectType(interaction.guild); - expectType>(interaction.reply({ content: 'a', withResponse: true })); - expectType>(interaction.deferReply({ withResponse: true })); + expectType>>(interaction.reply({ content: 'a', withResponse: true })); + expectType>>(interaction.deferReply({ withResponse: true })); expectType>>(interaction.deferReply()); expectType>>(interaction.reply({ content: 'a', withResponse: false })); expectType>>(interaction.deferReply({ withResponse: false })); expectType>>(interaction.editReply({ content: 'a' })); expectType>>(interaction.fetchReply()); expectType>>(interaction.followUp({ content: 'a' })); - expectType>(interaction.launchActivity({ withResponse: true })); + expectType>>(interaction.launchActivity({ withResponse: true })); expectType>(interaction.launchActivity({ withResponse: false })); } else if (interaction.inGuild()) { expectAssignable(interaction); @@ -2268,27 +2268,27 @@ client.on('interactionCreate', async interaction => { expectType(interaction.guild); expectType>>(interaction.reply({ content: 'a', fetchReply: true })); expectType>>(interaction.deferReply({ fetchReply: true })); - expectType>(interaction.reply({ content: 'a', withResponse: true })); - expectType>(interaction.deferReply({ withResponse: true })); + expectType>>(interaction.reply({ content: 'a', withResponse: true })); + expectType>>(interaction.deferReply({ withResponse: true })); expectType>>(interaction.editReply({ content: 'a' })); expectType>>(interaction.fetchReply()); expectType>>(interaction.deferUpdate({ fetchReply: true })); - expectType>(interaction.deferUpdate({ withResponse: true })); + expectType>>(interaction.deferUpdate({ withResponse: true })); expectType>>(interaction.followUp({ content: 'a' })); - expectType>(interaction.launchActivity({ withResponse: true })); + expectType>>(interaction.launchActivity({ withResponse: true })); } else if (interaction.inRawGuild()) { expectAssignable(interaction); expectType(interaction.guild); expectType>>(interaction.reply({ content: 'a', fetchReply: true })); expectType>>(interaction.deferReply({ fetchReply: true })); - expectType>(interaction.reply({ content: 'a', withResponse: true })); - expectType>(interaction.deferReply({ withResponse: true })); + expectType>>(interaction.reply({ content: 'a', withResponse: true })); + expectType>>(interaction.deferReply({ withResponse: true })); expectType>>(interaction.editReply({ content: 'a' })); expectType>>(interaction.fetchReply()); expectType>>(interaction.deferUpdate({ fetchReply: true })); - expectType>(interaction.deferUpdate({ withResponse: true })); + expectType>>(interaction.deferUpdate({ withResponse: true })); expectType>>(interaction.followUp({ content: 'a' })); - expectType>(interaction.launchActivity({ withResponse: true })); + expectType>>(interaction.launchActivity({ withResponse: true })); } else if (interaction.inGuild()) { expectAssignable(interaction); expectType(interaction.guild);