From 1bff7bc5bf6801bede74892dba65b772c827ec59 Mon Sep 17 00:00:00 2001 From: Naiyar <137700126+imnaiyar@users.noreply.github.com> Date: Fri, 6 Dec 2024 01:33:55 +0000 Subject: [PATCH 01/15] feat: add activity launch interaction response --- .../src/structures/CommandInteraction.js | 1 + .../structures/MessageComponentInteraction.js | 1 + .../src/structures/ModalSubmitInteraction.js | 1 + .../interfaces/InteractionResponses.js | 19 +++++++++++++++++++ packages/discord.js/typings/index.d.ts | 3 +++ 5 files changed, 25 insertions(+) diff --git a/packages/discord.js/src/structures/CommandInteraction.js b/packages/discord.js/src/structures/CommandInteraction.js index 88086f9605b2..b7fa18e91127 100644 --- a/packages/discord.js/src/structures/CommandInteraction.js +++ b/packages/discord.js/src/structures/CommandInteraction.js @@ -152,6 +152,7 @@ class CommandInteraction extends BaseInteraction { editReply() {} deleteReply() {} followUp() {} + launchActivity() {} showModal() {} awaitModalSubmit() {} } diff --git a/packages/discord.js/src/structures/MessageComponentInteraction.js b/packages/discord.js/src/structures/MessageComponentInteraction.js index 47b31e04c12c..1cd55bbe8629 100644 --- a/packages/discord.js/src/structures/MessageComponentInteraction.js +++ b/packages/discord.js/src/structures/MessageComponentInteraction.js @@ -98,6 +98,7 @@ class MessageComponentInteraction extends BaseInteraction { followUp() {} deferUpdate() {} update() {} + launchActivity() {} showModal() {} awaitModalSubmit() {} } diff --git a/packages/discord.js/src/structures/ModalSubmitInteraction.js b/packages/discord.js/src/structures/ModalSubmitInteraction.js index 559807bfa078..fd8ca10acce3 100644 --- a/packages/discord.js/src/structures/ModalSubmitInteraction.js +++ b/packages/discord.js/src/structures/ModalSubmitInteraction.js @@ -118,6 +118,7 @@ class ModalSubmitInteraction extends BaseInteraction { followUp() {} deferUpdate() {} update() {} + launchActivity() {} } InteractionResponses.applyToClass(ModalSubmitInteraction, 'showModal'); diff --git a/packages/discord.js/src/structures/interfaces/InteractionResponses.js b/packages/discord.js/src/structures/interfaces/InteractionResponses.js index 1cebca8f9ce6..eea285d9b5cc 100644 --- a/packages/discord.js/src/structures/interfaces/InteractionResponses.js +++ b/packages/discord.js/src/structures/interfaces/InteractionResponses.js @@ -269,6 +269,24 @@ class InteractionResponses { : new InteractionResponse(this, this.message.interaction?.id); } + /** + * Launches activity, if enabled + * @returns {Promise} + */ + async launchActivity() { + if (this.deferred || this.replied) throw new DiscordjsError(ErrorCodes.InteractionAlreadyReplied); + const response = await this.client.rest.post(Routes.interactionCallback(this.id, this.token), { + body: { + type: InteractionResponseType.LaunchActivity, + }, + auth: false, + query: makeURLSearchParams({ with_response: true }), + }); + this.replied = true; + + return new InteractionCallbackResponse(this.client, response); + } + /** * Shows a modal component * @param {ModalBuilder|ModalComponentData|APIModalInteractionResponseCallbackData} modal The modal to show @@ -332,6 +350,7 @@ class InteractionResponses { 'followUp', 'deferUpdate', 'update', + 'launchActivity', 'showModal', 'awaitModalSubmit', ]; diff --git a/packages/discord.js/typings/index.d.ts b/packages/discord.js/typings/index.d.ts index c4d5d22ed2b9..e9c163dbf3d9 100644 --- a/packages/discord.js/typings/index.d.ts +++ b/packages/discord.js/typings/index.d.ts @@ -582,6 +582,7 @@ export abstract class CommandInteraction e public reply( options: string | MessagePayload | InteractionReplyOptions, ): Promise>>; + public launchActivity(): Promise; public showModal( modal: | JSONEncodable @@ -2362,6 +2363,7 @@ export class MessageComponentInteraction e public update( options: string | MessagePayload | InteractionUpdateOptions, ): Promise>>; + public launchActivity(): Promise; public showModal( modal: | JSONEncodable @@ -2581,6 +2583,7 @@ export class ModalSubmitInteraction extend options: InteractionDeferUpdateOptions & { withResponse: true }, ): Promise; public deferUpdate(options?: InteractionDeferUpdateOptions): Promise>>; + public launchActivity(): Promise; public inGuild(): this is ModalSubmitInteraction<'raw' | 'cached'>; public inCachedGuild(): this is ModalSubmitInteraction<'cached'>; public inRawGuild(): this is ModalSubmitInteraction<'raw'>; From 5d7f8c25b29e6bf2450ae6f4e82d42b881bb390f Mon Sep 17 00:00:00 2001 From: Naiyar <137700126+imnaiyar@users.noreply.github.com> Date: Fri, 6 Dec 2024 06:39:48 +0000 Subject: [PATCH 02/15] feat: update application command --- .../src/managers/ApplicationCommandManager.js | 1 + .../src/structures/ApplicationCommand.js | 16 +++++++++++++++- packages/discord.js/src/util/APITypes.js | 5 +++++ packages/discord.js/typings/index.d.ts | 12 +++++++++++- 4 files changed, 32 insertions(+), 2 deletions(-) diff --git a/packages/discord.js/src/managers/ApplicationCommandManager.js b/packages/discord.js/src/managers/ApplicationCommandManager.js index 8f6ce53106d4..9a8fd2e9d7bc 100644 --- a/packages/discord.js/src/managers/ApplicationCommandManager.js +++ b/packages/discord.js/src/managers/ApplicationCommandManager.js @@ -261,6 +261,7 @@ class ApplicationCommandManager extends CachedManager { dm_permission: command.dmPermission ?? command.dm_permission, integration_types: command.integrationTypes ?? command.integration_types, contexts: command.contexts, + handler: command.handler, }; } } diff --git a/packages/discord.js/src/structures/ApplicationCommand.js b/packages/discord.js/src/structures/ApplicationCommand.js index 37eff9e46d5c..c72bed2771cf 100644 --- a/packages/discord.js/src/structures/ApplicationCommand.js +++ b/packages/discord.js/src/structures/ApplicationCommand.js @@ -174,6 +174,19 @@ class ApplicationCommand extends Base { this.contexts ??= null; } + if ('handler' in data) { + /** + * Determines whether the interaction is handled by the app's interactions handler or by Discord. + * Only available for {@link ApplicationCommandType.PrimaryEntryPoint} command + * and for apps with `EMBEDDED` flag (i.e, applications that have an Activity) + * + * @type {?EntryPointCommandHandlerType} + */ + this.handler = data.handler; + } else { + this.handler ??= null; + } + if ('version' in data) { /** * Autoincrementing version identifier updated during substantial record changes @@ -419,7 +432,8 @@ class ApplicationCommand extends Base { this.descriptionLocalizations ?? {}, ) || !isEqual(command.integrationTypes ?? command.integration_types ?? [], this.integrationTypes ?? []) || - !isEqual(command.contexts ?? [], this.contexts ?? []) + !isEqual(command.contexts ?? [], this.contexts ?? []) || + ('handler' in command && command.handler !== this.handler) ) { return false; } diff --git a/packages/discord.js/src/util/APITypes.js b/packages/discord.js/src/util/APITypes.js index 50a9f6c477ff..7abcf395bb53 100644 --- a/packages/discord.js/src/util/APITypes.js +++ b/packages/discord.js/src/util/APITypes.js @@ -320,6 +320,11 @@ * @see {@link https://discord-api-types.dev/api/discord-api-types-v10/enum/EntitlementType} */ +/** + * @external EntryPointCommandHandlerType + * @see {@link https://discord-api-types.dev/api/discord-api-types-v10/enum/EntryPointCommandHandlerType} + */ + /** * @external ForumLayoutType * @see {@link https://discord-api-types.dev/api/discord-api-types-v10/enum/ForumLayoutType} diff --git a/packages/discord.js/typings/index.d.ts b/packages/discord.js/typings/index.d.ts index e9c163dbf3d9..06222f365471 100644 --- a/packages/discord.js/typings/index.d.ts +++ b/packages/discord.js/typings/index.d.ts @@ -176,6 +176,7 @@ import { RESTAPIInteractionCallbackActivityInstanceResource, VoiceChannelEffectSendAnimationType, GatewayVoiceChannelEffectSendDispatchData, + EntryPointCommandHandlerType, } from 'discord-api-types/v10'; import { ChildProcess } from 'node:child_process'; import { EventEmitter } from 'node:events'; @@ -436,6 +437,7 @@ export class ApplicationCommand extends Base { public get manager(): ApplicationCommandManager; public id: Snowflake; public integrationTypes: ApplicationIntegrationType[] | null; + public handler: EntryPointCommandHandlerType | null; public name: string; public nameLocalizations: LocalizationMap | null; public nameLocalized: string | null; @@ -4754,10 +4756,18 @@ export interface ChatInputApplicationCommandData extends BaseApplicationCommandD options?: readonly ApplicationCommandOptionData[]; } +export interface PrimaryEntryPointCommandData extends BaseApplicationCommandData { + description?: string; + descriptionLocalizations?: LocalizationMap; + type: ApplicationCommandType.PrimaryEntryPoint; + handler?: EntryPointCommandHandlerType; +} + export type ApplicationCommandData = | UserApplicationCommandData | MessageApplicationCommandData - | ChatInputApplicationCommandData; + | ChatInputApplicationCommandData + | PrimaryEntryPointCommandData; export interface ApplicationCommandChannelOptionData extends BaseApplicationCommandOptionsData { type: CommandOptionChannelResolvableType; From 1083c69b5d8aa558beec1be375aedaedb200ba1c Mon Sep 17 00:00:00 2001 From: Naiyar <137700126+imnaiyar@users.noreply.github.com> Date: Sat, 7 Dec 2024 02:00:52 +0000 Subject: [PATCH 03/15] chore: update jsdocs --- .../discord.js/src/structures/ApplicationCommand.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/discord.js/src/structures/ApplicationCommand.js b/packages/discord.js/src/structures/ApplicationCommand.js index c72bed2771cf..4dfc79514c60 100644 --- a/packages/discord.js/src/structures/ApplicationCommand.js +++ b/packages/discord.js/src/structures/ApplicationCommand.js @@ -229,15 +229,20 @@ class ApplicationCommand extends Base { * @property {string} name The name of the command, must be in all lowercase if type is * {@link ApplicationCommandType.ChatInput} * @property {Object} [nameLocalizations] The localizations for the command name - * @property {string} description The description of the command, if type is {@link ApplicationCommandType.ChatInput} + * @property {string} description The description of the command, + * if type is {@link ApplicationCommandType.ChatInput} or {@link ApplicationCommandType.PrimaryEntryPoint} * @property {boolean} [nsfw] Whether the command is age-restricted * @property {Object} [descriptionLocalizations] The localizations for the command description, - * if type is {@link ApplicationCommandType.ChatInput} + * if type is {@link ApplicationCommandType.ChatInput} or {@link ApplicationCommandType.PrimaryEntryPoint} * @property {ApplicationCommandType} [type=ApplicationCommandType.ChatInput] The type of the command * @property {ApplicationCommandOptionData[]} [options] Options for the command * @property {?PermissionResolvable} [defaultMemberPermissions] The bitfield used to determine the default permissions * a member needs in order to run the command - * @property {boolean} [dmPermission] Whether the command is enabled in DMs + * @property {boolean} [dmPermission] Whether the command is enabled in DMs. + * Deprecated, use {@link ApplicationCommandData#contexts} instead. + * @property {ApplicationIntegrationType[]} [integrationTypes] Installation context(s) where the command is available + * @property {InteractionContextType[]} [contexts] Interaction context(s) where the command can be used + * @property {EntryPointCommandHandlerType} [handler] Determines whether the interaction is handled by the app's */ /** From 1d3a4e99bff69cd7548b9908dd5d81a043305445 Mon Sep 17 00:00:00 2001 From: Naiyar <137700126+imnaiyar@users.noreply.github.com> Date: Sat, 7 Dec 2024 03:14:16 +0000 Subject: [PATCH 04/15] feat: entry point command --- .../src/client/actions/InteractionCreate.js | 4 ++++ .../discord.js/src/structures/BaseInteraction.js | 10 ++++++++++ .../PrimaryEntryPointCommandInteraction.js | 10 ++++++++++ packages/discord.js/typings/index.d.ts | 16 ++++++++++++++-- 4 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 packages/discord.js/src/structures/PrimaryEntryPointCommandInteraction.js diff --git a/packages/discord.js/src/client/actions/InteractionCreate.js b/packages/discord.js/src/client/actions/InteractionCreate.js index 434fb0c0689c..ee04fa20bc08 100644 --- a/packages/discord.js/src/client/actions/InteractionCreate.js +++ b/packages/discord.js/src/client/actions/InteractionCreate.js @@ -9,6 +9,7 @@ const ChatInputCommandInteraction = require('../../structures/ChatInputCommandIn const MentionableSelectMenuInteraction = require('../../structures/MentionableSelectMenuInteraction'); const MessageContextMenuCommandInteraction = require('../../structures/MessageContextMenuCommandInteraction'); const ModalSubmitInteraction = require('../../structures/ModalSubmitInteraction'); +const PrimaryEntryPointCommandInteraction = require('../../structures/PrimaryEntryPointCommandInteraction'); const RoleSelectMenuInteraction = require('../../structures/RoleSelectMenuInteraction'); const StringSelectMenuInteraction = require('../../structures/StringSelectMenuInteraction'); const UserContextMenuCommandInteraction = require('../../structures/UserContextMenuCommandInteraction'); @@ -38,6 +39,9 @@ class InteractionCreateAction extends Action { if (channel && !channel.isTextBased()) return; InteractionClass = MessageContextMenuCommandInteraction; break; + case ApplicationCommandType.PrimaryEntryPoint: + InteractionClass = PrimaryEntryPointCommandInteraction; + break; default: client.emit( Events.Debug, diff --git a/packages/discord.js/src/structures/BaseInteraction.js b/packages/discord.js/src/structures/BaseInteraction.js index 1386a75f9eb4..bf74d9f7de13 100644 --- a/packages/discord.js/src/structures/BaseInteraction.js +++ b/packages/discord.js/src/structures/BaseInteraction.js @@ -218,6 +218,16 @@ class BaseInteraction extends Base { ); } + /** + * Indicates whether this interaction is a {@link PrimaryEntryPointCommandInteraction} + * @returns{boolean} + */ + isPrimaryEntryPointCommand() { + return ( + this.type === InteractionType.ApplicationCommand && this.commandType === ApplicationCommandType.PrimaryEntryPoint + ); + } + /** * Indicates whether this interaction is a {@link MessageComponentInteraction} * @returns {boolean} diff --git a/packages/discord.js/src/structures/PrimaryEntryPointCommandInteraction.js b/packages/discord.js/src/structures/PrimaryEntryPointCommandInteraction.js new file mode 100644 index 000000000000..611e5c065a8a --- /dev/null +++ b/packages/discord.js/src/structures/PrimaryEntryPointCommandInteraction.js @@ -0,0 +1,10 @@ +'use strict'; + +const CommandInteraction = require('./CommandInteraction'); +/** + * Represents a context menu interaction. + * @extends {CommandInteraction} + */ +class PrimaryEntryPointCommandInteraction extends CommandInteraction {} + +module.exports = PrimaryEntryPointCommandInteraction; diff --git a/packages/discord.js/typings/index.d.ts b/packages/discord.js/typings/index.d.ts index 06222f365471..2171536508ed 100644 --- a/packages/discord.js/typings/index.d.ts +++ b/packages/discord.js/typings/index.d.ts @@ -177,6 +177,7 @@ import { VoiceChannelEffectSendAnimationType, GatewayVoiceChannelEffectSendDispatchData, EntryPointCommandHandlerType, + APIPrimaryEntryPointCommandInteractionData, } from 'discord-api-types/v10'; import { ChildProcess } from 'node:child_process'; import { EventEmitter } from 'node:events'; @@ -604,7 +605,7 @@ export abstract class CommandInteraction e ): Promise>; private transformOption( option: APIApplicationCommandOption, - resolved: APIApplicationCommandInteractionData['resolved'], + resolved: Exclude['resolved'], ): CommandInteractionOption; } @@ -1321,6 +1322,15 @@ export class ContextMenuCommandInteraction private resolveContextMenuOptions(data: APIApplicationCommandInteractionData): CommandInteractionOption[]; } +export class PrimaryEntryPointCommandInteraction< + Cached extends CacheType = CacheType, +> extends CommandInteraction { + public commandType: ApplicationCommandType.PrimaryEntryPoint; + public inGuild(): this is ContextMenuCommandInteraction<'raw' | 'cached'>; + public inCachedGuild(): this is ContextMenuCommandInteraction<'cached'>; + public inRawGuild(): this is ContextMenuCommandInteraction<'raw'>; +} + /** @internal */ export interface ResolvedFile { data: Buffer; @@ -1941,6 +1951,7 @@ export type Interaction = | ChatInputCommandInteraction | MessageContextMenuCommandInteraction | UserContextMenuCommandInteraction + | PrimaryEntryPointCommandInteraction | SelectMenuInteraction | ButtonInteraction | AutocompleteInteraction @@ -1989,6 +2000,7 @@ export class BaseInteraction extends Base public isChatInputCommand(): this is ChatInputCommandInteraction; public isCommand(): this is CommandInteraction; public isContextMenuCommand(): this is ContextMenuCommandInteraction; + public isPrimaryEntryPointCommand(): this is PrimaryEntryPointCommandInteraction; public isMessageComponent(): this is MessageComponentInteraction; public isMessageContextMenuCommand(): this is MessageContextMenuCommandInteraction; public isModalSubmit(): this is ModalSubmitInteraction; @@ -3567,7 +3579,7 @@ export function parseWebhookURL(url: string): WebhookClientDataIdWithToken | nul /** @internal */ export function transformResolved( supportingData: SupportingInteractionResolvedData, - data?: APIApplicationCommandInteractionData['resolved'], + data?: Exclude['resolved'], ): CommandInteractionResolvedData; export function resolveSKUId(resolvable: SKUResolvable): Snowflake | null; From 7d87b14016440b742e742a56f6bf5d4e0e6d78ee Mon Sep 17 00:00:00 2001 From: Naiyar <137700126+imnaiyar@users.noreply.github.com> Date: Sat, 7 Dec 2024 09:39:24 +0600 Subject: [PATCH 05/15] fix: typeguard --- packages/discord.js/typings/index.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/discord.js/typings/index.d.ts b/packages/discord.js/typings/index.d.ts index 2171536508ed..f13d81e748d4 100644 --- a/packages/discord.js/typings/index.d.ts +++ b/packages/discord.js/typings/index.d.ts @@ -1326,9 +1326,9 @@ export class PrimaryEntryPointCommandInteraction< Cached extends CacheType = CacheType, > extends CommandInteraction { public commandType: ApplicationCommandType.PrimaryEntryPoint; - public inGuild(): this is ContextMenuCommandInteraction<'raw' | 'cached'>; - public inCachedGuild(): this is ContextMenuCommandInteraction<'cached'>; - public inRawGuild(): this is ContextMenuCommandInteraction<'raw'>; + public inGuild(): this is PrimaryEntryPointCommandInteraction<'raw' | 'cached'>; + public inCachedGuild(): this is PrimaryEntryPointCommandInteraction<'cached'>; + public inRawGuild(): this is PrimaryEntryPointCommandInteraction<'raw'>; } /** @internal */ From dc627f7b7bef0308744030b4e760228722916ca2 Mon Sep 17 00:00:00 2001 From: Naiyar <137700126+imnaiyar@users.noreply.github.com> Date: Sat, 7 Dec 2024 09:43:37 +0600 Subject: [PATCH 06/15] fix: jsdoc --- .../src/structures/PrimaryEntryPointCommandInteraction.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/discord.js/src/structures/PrimaryEntryPointCommandInteraction.js b/packages/discord.js/src/structures/PrimaryEntryPointCommandInteraction.js index 611e5c065a8a..cfca7cdbcebc 100644 --- a/packages/discord.js/src/structures/PrimaryEntryPointCommandInteraction.js +++ b/packages/discord.js/src/structures/PrimaryEntryPointCommandInteraction.js @@ -2,7 +2,7 @@ const CommandInteraction = require('./CommandInteraction'); /** - * Represents a context menu interaction. + * Represents a primary entry point command interaction. * @extends {CommandInteraction} */ class PrimaryEntryPointCommandInteraction extends CommandInteraction {} From c537f12bda546d0fd00aa57ebd866f434ea40a6c Mon Sep 17 00:00:00 2001 From: Naiyar <137700126+imnaiyar@users.noreply.github.com> Date: Sat, 7 Dec 2024 05:37:27 +0000 Subject: [PATCH 07/15] chore: update typings --- packages/discord.js/typings/index.d.ts | 34 +++++++++++++------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/packages/discord.js/typings/index.d.ts b/packages/discord.js/typings/index.d.ts index f13d81e748d4..44a1608c0a4e 100644 --- a/packages/discord.js/typings/index.d.ts +++ b/packages/discord.js/typings/index.d.ts @@ -542,23 +542,6 @@ export type BooleanCache = Cached extends 'cached' ? t export abstract class CommandInteraction extends BaseInteraction { public type: InteractionType.ApplicationCommand; public get command(): ApplicationCommand | ApplicationCommand<{ guild: GuildResolvable }> | null; - public options: Omit< - CommandInteractionOptionResolver, - | 'getMessage' - | 'getFocused' - | 'getMentionable' - | 'getRole' - | 'getUser' - | 'getMember' - | 'getAttachment' - | 'getNumber' - | 'getInteger' - | 'getString' - | 'getChannel' - | 'getBoolean' - | 'getSubcommandGroup' - | 'getSubcommand' - >; public channelId: Snowflake; public commandId: Snowflake; public commandName: string; @@ -1314,6 +1297,23 @@ export class CommandInteractionOptionResolver extends CommandInteraction { + public options: Omit< + CommandInteractionOptionResolver, + | 'getMessage' + | 'getFocused' + | 'getMentionable' + | 'getRole' + | 'getUser' + | 'getMember' + | 'getAttachment' + | 'getNumber' + | 'getInteger' + | 'getString' + | 'getChannel' + | 'getBoolean' + | 'getSubcommandGroup' + | 'getSubcommand' + >; public commandType: ApplicationCommandType.Message | ApplicationCommandType.User; public targetId: Snowflake; public inGuild(): this is ContextMenuCommandInteraction<'raw' | 'cached'>; From 7b5ba2daa12512e3fd64d8a46133fdb7383286e6 Mon Sep 17 00:00:00 2001 From: Naiyar <137700126+imnaiyar@users.noreply.github.com> Date: Sat, 7 Dec 2024 18:52:45 +0000 Subject: [PATCH 08/15] chore: export class --- packages/discord.js/src/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/discord.js/src/index.js b/packages/discord.js/src/index.js index d2f0ff799947..4ccbaf81d16d 100644 --- a/packages/discord.js/src/index.js +++ b/packages/discord.js/src/index.js @@ -171,6 +171,7 @@ exports.PartialGroupDMChannel = require('./structures/PartialGroupDMChannel'); exports.PermissionOverwrites = require('./structures/PermissionOverwrites'); exports.Poll = require('./structures/Poll').Poll; exports.PollAnswer = require('./structures/PollAnswer').PollAnswer; +exports.PrimaryEntryPointCommandInteraction = require('./structures/PrimaryEntryPointCommandInteraction'); exports.Presence = require('./structures/Presence').Presence; exports.ReactionCollector = require('./structures/ReactionCollector'); exports.ReactionEmoji = require('./structures/ReactionEmoji'); From 1ec61de92c0a9fb201c0e37a97b0e8574dfc76d0 Mon Sep 17 00:00:00 2001 From: Naiyar <137700126+imnaiyar@users.noreply.github.com> Date: Mon, 9 Dec 2024 16:30:19 +0000 Subject: [PATCH 09/15] refactor: add LaunchActivityOptions --- .../structures/interfaces/InteractionResponses.js | 15 +++++++++++---- packages/discord.js/typings/index.d.ts | 13 ++++++++++--- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/packages/discord.js/src/structures/interfaces/InteractionResponses.js b/packages/discord.js/src/structures/interfaces/InteractionResponses.js index eea285d9b5cc..3b74bbec3c75 100644 --- a/packages/discord.js/src/structures/interfaces/InteractionResponses.js +++ b/packages/discord.js/src/structures/interfaces/InteractionResponses.js @@ -51,6 +51,12 @@ class InteractionResponses { * @property {boolean} [withResponse] Whether to return an {@link InteractionCallbackResponse} as the response */ + /** + * Options for launching activity in response to a {@link BaseInteraction} + * @typedef {Object} LaunchActivityOptions + * @property {boolean} [withResponse] Whether to return an {@link InteractionCallbackResponse} as the response + */ + /** * Options for showing a modal in response to a {@link BaseInteraction} * @typedef {Object} ShowModalOptions @@ -271,20 +277,21 @@ class InteractionResponses { /** * Launches activity, if enabled - * @returns {Promise} + * @param {LaunchActivityOptions} [options={}] Options for launching the activity + * @returns {Promise} */ - async launchActivity() { + async launchActivity({ withResponse } = {}) { if (this.deferred || this.replied) throw new DiscordjsError(ErrorCodes.InteractionAlreadyReplied); const response = await this.client.rest.post(Routes.interactionCallback(this.id, this.token), { + query: makeURLSearchParams({ with_response: withResponse ?? false }), body: { type: InteractionResponseType.LaunchActivity, }, auth: false, - query: makeURLSearchParams({ with_response: true }), }); this.replied = true; - return new InteractionCallbackResponse(this.client, response); + return withResponse ? new InteractionCallbackResponse(this.client, response) : undefined; } /** diff --git a/packages/discord.js/typings/index.d.ts b/packages/discord.js/typings/index.d.ts index ff1adc262956..74ff4b2c4bb8 100644 --- a/packages/discord.js/typings/index.d.ts +++ b/packages/discord.js/typings/index.d.ts @@ -565,7 +565,8 @@ export abstract class CommandInteraction e public reply( options: string | MessagePayload | InteractionReplyOptions, ): Promise>>; - public launchActivity(): Promise; + public launchActivity(options: LaunchActivityOptions & { withResponse: true }): Promise; + public launchActivity(options?: LaunchActivityOptions): Promise; public showModal( modal: | JSONEncodable @@ -2372,7 +2373,8 @@ export class MessageComponentInteraction e public update( options: string | MessagePayload | InteractionUpdateOptions, ): Promise>>; - public launchActivity(): Promise; + public launchActivity(options: LaunchActivityOptions & { withResponse: true }): Promise; + public launchActivity(options?: LaunchActivityOptions): Promise; public showModal( modal: | JSONEncodable @@ -2592,7 +2594,8 @@ export class ModalSubmitInteraction extend options: InteractionDeferUpdateOptions & { withResponse: true }, ): Promise; public deferUpdate(options?: InteractionDeferUpdateOptions): Promise>>; - public launchActivity(): Promise; + public launchActivity(options: LaunchActivityOptions & { withResponse: true }): Promise; + public launchActivity(options?: LaunchActivityOptions): Promise; public inGuild(): this is ModalSubmitInteraction<'raw' | 'cached'>; public inCachedGuild(): this is ModalSubmitInteraction<'cached'>; public inRawGuild(): this is ModalSubmitInteraction<'raw'>; @@ -6748,6 +6751,10 @@ export interface ShowModalOptions { withResponse?: boolean; } +export interface LaunchActivityOptions { + withResponse?: boolean; +} + export { Snowflake }; export type StageInstanceResolvable = StageInstance | Snowflake; From cdf5a432940cbb8c2a00f5e7d9904ebd85c99f68 Mon Sep 17 00:00:00 2001 From: Naiyar <137700126+imnaiyar@users.noreply.github.com> Date: Mon, 9 Dec 2024 16:35:47 +0000 Subject: [PATCH 10/15] fix: jsdoc --- packages/discord.js/src/structures/BaseInteraction.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/discord.js/src/structures/BaseInteraction.js b/packages/discord.js/src/structures/BaseInteraction.js index bf74d9f7de13..ae74db9674c6 100644 --- a/packages/discord.js/src/structures/BaseInteraction.js +++ b/packages/discord.js/src/structures/BaseInteraction.js @@ -220,7 +220,7 @@ class BaseInteraction extends Base { /** * Indicates whether this interaction is a {@link PrimaryEntryPointCommandInteraction} - * @returns{boolean} + * @returns {boolean} */ isPrimaryEntryPointCommand() { return ( From ddf687f17907cdc5ee2ab38b561848931415009f Mon Sep 17 00:00:00 2001 From: Naiyar <137700126+imnaiyar@users.noreply.github.com> Date: Mon, 9 Dec 2024 16:41:49 +0000 Subject: [PATCH 11/15] feat: add tests --- packages/discord.js/typings/index.test-d.ts | 49 +++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/packages/discord.js/typings/index.test-d.ts b/packages/discord.js/typings/index.test-d.ts index 266205746467..d5e65a6713f1 100644 --- a/packages/discord.js/typings/index.test-d.ts +++ b/packages/discord.js/typings/index.test-d.ts @@ -209,6 +209,7 @@ import { SendableChannels, PollData, InteractionCallbackResponse, + PrimaryEntryPointCommandInteraction, } from '.'; import { expectAssignable, expectNotAssignable, expectNotType, expectType } from 'tsd'; import type { ContextMenuCommandBuilder, SlashCommandBuilder } from '@discordjs/builders'; @@ -1792,6 +1793,7 @@ client.on('interactionCreate', async interaction => { expectType>(interaction.update({ content: 'a', withResponse: true })); expectType>(interaction.deferUpdate({ withResponse: true })); expectType>>(interaction.followUp({ content: 'a' })); + expectType>(interaction.launchActivity({ withResponse: true })); } else if (interaction.inRawGuild()) { expectAssignable(interaction); expectType(interaction.component); @@ -1804,6 +1806,7 @@ client.on('interactionCreate', async interaction => { expectType>(interaction.update({ content: 'a', withResponse: true })); expectType>(interaction.deferUpdate({ withResponse: true })); expectType>>(interaction.followUp({ content: 'a' })); + expectType>(interaction.launchActivity({ withResponse: true })); } else if (interaction.inGuild()) { expectAssignable(interaction); expectType(interaction.component); @@ -1816,6 +1819,7 @@ client.on('interactionCreate', async interaction => { expectType>(interaction.update({ content: 'a', withResponse: true })); expectType>(interaction.deferUpdate({ withResponse: true })); expectType>(interaction.followUp({ content: 'a' })); + expectType>(interaction.launchActivity({ withResponse: true })); } } @@ -1853,6 +1857,7 @@ client.on('interactionCreate', async interaction => { expectType>>(interaction.editReply({ content: 'a' })); expectType>>(interaction.fetchReply()); expectType>>(interaction.followUp({ content: 'a' })); + expectType>(interaction.launchActivity({ withResponse: true })); } else if (interaction.inRawGuild()) { expectAssignable(interaction); expectType(interaction.guild); @@ -1861,6 +1866,7 @@ client.on('interactionCreate', async interaction => { expectType>>(interaction.editReply({ content: 'a' })); expectType>>(interaction.fetchReply()); expectType>>(interaction.followUp({ content: 'a' })); + expectType>(interaction.launchActivity({ withResponse: true })); } else if (interaction.inGuild()) { expectAssignable(interaction); expectType(interaction.guild); @@ -1869,6 +1875,7 @@ client.on('interactionCreate', async interaction => { expectType>(interaction.editReply({ content: 'a' })); expectType>(interaction.fetchReply()); expectType>(interaction.followUp({ content: 'a' })); + expectType>(interaction.launchActivity({ withResponse: true })); } } @@ -2037,6 +2044,45 @@ client.on('interactionCreate', async interaction => { interaction.options.getMessage('name'); } + if ( + interaction.type === InteractionType.ApplicationCommand && + interaction.commandType === ApplicationCommandType.PrimaryEntryPoint + ) { + expectType(interaction); + + // @ts-expect-error No options on primary entry point commands + interaction.options; + if (interaction.inCachedGuild()) { + expectAssignable(interaction); + expectAssignable(interaction.guild); + expectAssignable>(interaction); + 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 })); + } else if (interaction.inRawGuild()) { + expectAssignable(interaction); + expectType(interaction.guild); + 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 })); + } else if (interaction.inGuild()) { + expectAssignable(interaction); + expectType(interaction.guild); + 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 })); + } + } + if (interaction.isRepliable()) { expectAssignable(interaction); interaction.reply('test'); @@ -2063,6 +2109,7 @@ client.on('interactionCreate', async interaction => { expectType>>(interaction.fetchReply()); expectType>(interaction.deferUpdate({ withResponse: true })); expectType>>(interaction.followUp({ content: 'a' })); + expectType>(interaction.launchActivity({ withResponse: true })); } else if (interaction.inRawGuild()) { expectAssignable(interaction); expectType(interaction.guild); @@ -2072,6 +2119,7 @@ client.on('interactionCreate', async interaction => { expectType>>(interaction.fetchReply()); expectType>(interaction.deferUpdate({ withResponse: true })); expectType>>(interaction.followUp({ content: 'a' })); + expectType>(interaction.launchActivity({ withResponse: true })); } else if (interaction.inGuild()) { expectAssignable(interaction); expectType(interaction.guild); @@ -2081,6 +2129,7 @@ client.on('interactionCreate', async interaction => { expectType>(interaction.fetchReply()); expectType>(interaction.deferUpdate({ withResponse: true })); expectType>(interaction.followUp({ content: 'a' })); + expectType>(interaction.launchActivity({ withResponse: true })); } } }); From 4d9f63232de7cd5d3ab6eeb7531f66daeb5c7002 Mon Sep 17 00:00:00 2001 From: Naiyar <137700126+imnaiyar@users.noreply.github.com> Date: Wed, 1 Jan 2025 11:03:37 +0000 Subject: [PATCH 12/15] chore: refactor --- packages/discord.js/src/structures/ApplicationCommand.js | 7 ++++++- packages/discord.js/src/util/APITypes.js | 5 ----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/discord.js/src/structures/ApplicationCommand.js b/packages/discord.js/src/structures/ApplicationCommand.js index 293d87f7fda2..c6f8bc59ab4c 100644 --- a/packages/discord.js/src/structures/ApplicationCommand.js +++ b/packages/discord.js/src/structures/ApplicationCommand.js @@ -166,7 +166,7 @@ class ApplicationCommand extends Base { /** * Determines whether the interaction is handled by the app's interactions handler or by Discord. * Only available for {@link ApplicationCommandType.PrimaryEntryPoint} command - * and for apps with `EMBEDDED` flag (i.e, applications that have an Activity) + * and for apps with {@link ApplicationFlags.Embedded} flag (i.e, applications that have an Activity) * * @type {?EntryPointCommandHandlerType} */ @@ -613,3 +613,8 @@ module.exports = ApplicationCommand; * @external ApplicationCommandOptionAllowedChannelTypes * @see {@link https://discord.js.org/docs/packages/builders/stable/ApplicationCommandOptionAllowedChannelTypes:TypeAlias} */ + +/** + * @external EntryPointCommandHandlerType + * @see {@link https://discord-api-types.dev/api/discord-api-types-v10/enum/EntryPointCommandHandlerType} + */ diff --git a/packages/discord.js/src/util/APITypes.js b/packages/discord.js/src/util/APITypes.js index 7abcf395bb53..50a9f6c477ff 100644 --- a/packages/discord.js/src/util/APITypes.js +++ b/packages/discord.js/src/util/APITypes.js @@ -320,11 +320,6 @@ * @see {@link https://discord-api-types.dev/api/discord-api-types-v10/enum/EntitlementType} */ -/** - * @external EntryPointCommandHandlerType - * @see {@link https://discord-api-types.dev/api/discord-api-types-v10/enum/EntryPointCommandHandlerType} - */ - /** * @external ForumLayoutType * @see {@link https://discord-api-types.dev/api/discord-api-types-v10/enum/ForumLayoutType} From e27a5e2c091198ebc529b71385112ed83498f4ba Mon Sep 17 00:00:00 2001 From: Naiyar <137700126+imnaiyar@users.noreply.github.com> Date: Mon, 13 Jan 2025 22:46:56 +0530 Subject: [PATCH 13/15] chore: lint --- packages/discord.js/typings/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/discord.js/typings/index.d.ts b/packages/discord.js/typings/index.d.ts index a1a3fd079aa1..3d11b8ddd0a5 100644 --- a/packages/discord.js/typings/index.d.ts +++ b/packages/discord.js/typings/index.d.ts @@ -2363,7 +2363,7 @@ export class MessageComponentInteraction e 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): Promise; public showModal( modal: From a801e0a3ee657cdf6f72bd934a14c435ffda8ef6 Mon Sep 17 00:00:00 2001 From: Naiyar <137700126+imnaiyar@users.noreply.github.com> Date: Mon, 13 Jan 2025 23:16:22 +0530 Subject: [PATCH 14/15] fix: overload --- packages/discord.js/typings/index.d.ts | 9 ++- packages/discord.js/typings/index.test-d.ts | 63 +++++++++++++++++++++ 2 files changed, 69 insertions(+), 3 deletions(-) diff --git a/packages/discord.js/typings/index.d.ts b/packages/discord.js/typings/index.d.ts index 3d11b8ddd0a5..1d33b56ad38f 100644 --- a/packages/discord.js/typings/index.d.ts +++ b/packages/discord.js/typings/index.d.ts @@ -573,7 +573,8 @@ export abstract class CommandInteraction e options: string | MessagePayload | InteractionReplyOptions, ): Promise; public launchActivity(options: LaunchActivityOptions & { withResponse: true }): Promise; - public launchActivity(options?: LaunchActivityOptions): Promise; + public launchActivity(options: LaunchActivityOptions & { withResponse?: false }): Promise; + public launchActivity(options?: LaunchActivityOptions): Promise; public showModal( modal: | JSONEncodable @@ -2364,7 +2365,8 @@ export class MessageComponentInteraction e options: string | MessagePayload | InteractionUpdateOptions, ): Promise; public launchActivity(options: LaunchActivityOptions & { withResponse: true }): Promise; - public launchActivity(options?: LaunchActivityOptions): Promise; + public launchActivity(options: LaunchActivityOptions & { withResponse?: false }): Promise; + public launchActivity(options?: LaunchActivityOptions): Promise; public showModal( modal: | JSONEncodable @@ -2594,7 +2596,8 @@ export class ModalSubmitInteraction extend public deferUpdate(options?: InteractionDeferUpdateOptions & { withResponse: false }): Promise; public deferUpdate(options?: InteractionDeferUpdateOptions): Promise; public launchActivity(options: LaunchActivityOptions & { withResponse: true }): Promise; - public launchActivity(options?: LaunchActivityOptions): Promise; + public launchActivity(options: LaunchActivityOptions & { withResponse?: false }): Promise; + public launchActivity(options?: LaunchActivityOptions): Promise; 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 78274093d563..1bdc786bcc3a 100644 --- a/packages/discord.js/typings/index.test-d.ts +++ b/packages/discord.js/typings/index.test-d.ts @@ -1808,6 +1808,10 @@ client.on('interactionCreate', async interaction => { expectType>(interaction.deferUpdate()); expectType>>(interaction.followUp({ content: 'a' })); expectType>(interaction.launchActivity({ withResponse: true })); + expectType>(interaction.launchActivity({ withResponse: false })); + expectType>( + interaction.launchActivity({ withResponse: booleanValue }), + ); } else if (interaction.inRawGuild()) { expectAssignable(interaction); expectType(interaction.component); @@ -1835,6 +1839,10 @@ client.on('interactionCreate', async interaction => { expectType>(interaction.deferUpdate()); expectType>>(interaction.followUp({ content: 'a' })); expectType>(interaction.launchActivity({ withResponse: true })); + expectType>(interaction.launchActivity({ withResponse: false })); + expectType>( + interaction.launchActivity({ withResponse: booleanValue }), + ); } else if (interaction.inGuild()) { expectAssignable(interaction); expectType(interaction.component); @@ -1862,6 +1870,10 @@ client.on('interactionCreate', async interaction => { expectType>(interaction.deferUpdate()); expectType>(interaction.followUp({ content: 'a' })); expectType>(interaction.launchActivity({ withResponse: true })); + expectType>(interaction.launchActivity({ withResponse: false })); + expectType>( + interaction.launchActivity({ withResponse: booleanValue }), + ); } } @@ -1909,6 +1921,10 @@ client.on('interactionCreate', async interaction => { expectType>>(interaction.fetchReply()); expectType>>(interaction.followUp({ content: 'a' })); expectType>(interaction.launchActivity({ withResponse: true })); + expectType>(interaction.launchActivity({ withResponse: false })); + expectType>( + interaction.launchActivity({ withResponse: booleanValue }), + ); } else if (interaction.inRawGuild()) { expectAssignable(interaction); expectType(interaction.guild); @@ -1927,6 +1943,10 @@ client.on('interactionCreate', async interaction => { expectType>>(interaction.fetchReply()); expectType>>(interaction.followUp({ content: 'a' })); expectType>(interaction.launchActivity({ withResponse: true })); + expectType>(interaction.launchActivity({ withResponse: false })); + expectType>( + interaction.launchActivity({ withResponse: booleanValue }), + ); } else if (interaction.inGuild()) { expectAssignable(interaction); expectType(interaction.guild); @@ -1945,6 +1965,10 @@ client.on('interactionCreate', async interaction => { expectType>(interaction.fetchReply()); expectType>(interaction.followUp({ content: 'a' })); expectType>(interaction.launchActivity({ withResponse: true })); + expectType>(interaction.launchActivity({ withResponse: false })); + expectType>( + interaction.launchActivity({ withResponse: booleanValue }), + ); } } @@ -2127,28 +2151,67 @@ client.on('interactionCreate', async interaction => { expectAssignable>(interaction); 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.reply({ content: 'a', withResponse: booleanValue }), + ); + expectType>( + interaction.deferReply({ withResponse: booleanValue }), + ); expectType>>(interaction.editReply({ content: 'a' })); expectType>>(interaction.fetchReply()); expectType>>(interaction.followUp({ content: 'a' })); expectType>(interaction.launchActivity({ withResponse: true })); + expectType>(interaction.launchActivity({ withResponse: false })); + expectType>( + interaction.launchActivity({ withResponse: booleanValue }), + ); } else if (interaction.inRawGuild()) { expectAssignable(interaction); expectType(interaction.guild); 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.reply({ content: 'a', withResponse: booleanValue }), + ); + expectType>( + interaction.deferReply({ withResponse: booleanValue }), + ); expectType>>(interaction.editReply({ content: 'a' })); expectType>>(interaction.fetchReply()); expectType>>(interaction.followUp({ content: 'a' })); expectType>(interaction.launchActivity({ withResponse: true })); + expectType>(interaction.launchActivity({ withResponse: false })); + expectType>( + interaction.launchActivity({ withResponse: booleanValue }), + ); } else if (interaction.inGuild()) { expectAssignable(interaction); expectType(interaction.guild); 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.reply({ content: 'a', withResponse: booleanValue }), + ); + expectType>( + interaction.deferReply({ withResponse: booleanValue }), + ); expectType>(interaction.editReply({ content: 'a' })); expectType>(interaction.fetchReply()); expectType>(interaction.followUp({ content: 'a' })); expectType>(interaction.launchActivity({ withResponse: true })); + expectType>(interaction.launchActivity({ withResponse: false })); + expectType>( + interaction.launchActivity({ withResponse: booleanValue }), + ); } } From a858294d9c635b7c9841adb1f5ef9fdb6d336a39 Mon Sep 17 00:00:00 2001 From: Naiyar <137700126+imnaiyar@users.noreply.github.com> Date: Mon, 13 Jan 2025 23:21:44 +0530 Subject: [PATCH 15/15] chore: overload --- packages/discord.js/typings/index.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/discord.js/typings/index.d.ts b/packages/discord.js/typings/index.d.ts index 1d33b56ad38f..45f70e92fadf 100644 --- a/packages/discord.js/typings/index.d.ts +++ b/packages/discord.js/typings/index.d.ts @@ -573,7 +573,7 @@ export abstract class CommandInteraction e options: string | MessagePayload | InteractionReplyOptions, ): Promise; public launchActivity(options: LaunchActivityOptions & { withResponse: true }): Promise; - public launchActivity(options: LaunchActivityOptions & { withResponse?: false }): Promise; + public launchActivity(options?: LaunchActivityOptions & { withResponse?: false }): Promise; public launchActivity(options?: LaunchActivityOptions): Promise; public showModal( modal: @@ -2365,7 +2365,7 @@ export class MessageComponentInteraction e options: string | MessagePayload | InteractionUpdateOptions, ): Promise; public launchActivity(options: LaunchActivityOptions & { withResponse: true }): Promise; - public launchActivity(options: LaunchActivityOptions & { withResponse?: false }): Promise; + public launchActivity(options?: LaunchActivityOptions & { withResponse?: false }): Promise; public launchActivity(options?: LaunchActivityOptions): Promise; public showModal( modal: @@ -2596,7 +2596,7 @@ export class ModalSubmitInteraction extend public deferUpdate(options?: InteractionDeferUpdateOptions & { withResponse: false }): Promise; public deferUpdate(options?: InteractionDeferUpdateOptions): Promise; public launchActivity(options: LaunchActivityOptions & { withResponse: true }): Promise; - public launchActivity(options: LaunchActivityOptions & { withResponse?: false }): Promise; + public launchActivity(options?: LaunchActivityOptions & { withResponse?: false }): Promise; public launchActivity(options?: LaunchActivityOptions): Promise; public inGuild(): this is ModalSubmitInteraction<'raw' | 'cached'>; public inCachedGuild(): this is ModalSubmitInteraction<'cached'>;