diff --git a/deno/utils/v10.ts b/deno/utils/v10.ts index 7349962a..c5dd5125 100644 --- a/deno/utils/v10.ts +++ b/deno/utils/v10.ts @@ -15,13 +15,14 @@ import type { APIMessageComponentGuildInteraction, APIMessageComponentInteraction, APIMessageComponentSelectMenuInteraction, + APIModalSubmitInteraction, } from '../payloads/v10/mod.ts'; import { ApplicationCommandType, ButtonStyle, ComponentType, InteractionType } from '../payloads/v10/mod.ts'; // Interactions /** - * A type-guard check for DM interactions + * A type guard check for DM interactions * * @param interaction - The interaction to check against * @returns A boolean that indicates if the interaction was received in a DM channel @@ -31,7 +32,7 @@ export function isDMInteraction(interaction: APIInteraction): interaction is API } /** - * A type-guard check for guild interactions + * A type guard check for guild interactions * * @param interaction - The interaction to check against * @returns A boolean that indicates if the interaction was received in a guild @@ -43,7 +44,7 @@ export function isGuildInteraction(interaction: APIInteraction): interaction is // ApplicationCommandInteractions /** - * A type-guard check for DM application command interactions + * A type guard check for DM application command interactions * * @param interaction - The application command interaction to check against * @returns A boolean that indicates if the application command interaction was received in a DM channel @@ -55,7 +56,7 @@ export function isApplicationCommandDMInteraction( } /** - * A type-guard check for guild application command interactions + * A type guard check for guild application command interactions * * @param interaction - The interaction to check against * @returns A boolean that indicates if the application command interaction was received in a guild @@ -69,7 +70,7 @@ export function isApplicationCommandGuildInteraction( // MessageComponentInteractions /** - * A type-guard check for DM message component interactions + * A type guard check for DM message component interactions * * @param interaction - The message component interaction to check against * @returns A boolean that indicates if the message component interaction was received in a DM channel @@ -81,7 +82,7 @@ export function isMessageComponentDMInteraction( } /** - * A type-guard check for guild message component interactions + * A type guard check for guild message component interactions * * @param interaction - The interaction to check against * @returns A boolean that indicates if the message component interaction was received in a guild @@ -95,7 +96,7 @@ export function isMessageComponentGuildInteraction( // Buttons /** - * A type-guard check for buttons that have a `url` attached to them. + * A type guard check for buttons that have a `url` attached to them. * * @param component - The button to check against * @returns A boolean that indicates if the button has a `url` attached to it @@ -105,7 +106,7 @@ export function isLinkButton(component: APIButtonComponent): component is APIBut } /** - * A type-guard check for buttons that have a `custom_id` attached to them. + * A type guard check for buttons that have a `custom_id` attached to them. * * @param component - The button to check against * @returns A boolean that indicates if the button has a `custom_id` attached to it @@ -114,10 +115,22 @@ export function isInteractionButton(component: APIButtonComponent): component is return ![ButtonStyle.Link, ButtonStyle.Premium].includes(component.style); } +// Modal + +/** + * A type guard check for modals submit interactions + * + * @param interaction - The interaction to check against + * @returns A boolean that indicates if the interaction is a modal submission + */ +export function isModalSubmitInteraction(interaction: APIInteraction): interaction is APIModalSubmitInteraction { + return interaction.type === InteractionType.ModalSubmit; +} + // Message Components /** - * A type-guard check for message component interactions + * A type guard check for message component interactions * * @param interaction - The interaction to check against * @returns A boolean that indicates if the interaction is a message component @@ -129,7 +142,7 @@ export function isMessageComponentInteraction( } /** - * A type-guard check for button message component interactions + * A type guard check for button message component interactions * * @param interaction - The message component interaction to check against * @returns A boolean that indicates if the message component is a button @@ -141,7 +154,7 @@ export function isMessageComponentButtonInteraction( } /** - * A type-guard check for select menu message component interactions + * A type guard check for select menu message component interactions * * @param interaction - The message component interaction to check against * @returns A boolean that indicates if the message component is a select menu @@ -161,7 +174,7 @@ export function isMessageComponentSelectMenuInteraction( // Application Commands /** - * A type-guard check for chat input application commands. + * A type guard check for chat input application commands. * * @param interaction - The interaction to check against * @returns A boolean that indicates if the interaction is a chat input application command @@ -173,7 +186,7 @@ export function isChatInputApplicationCommandInteraction( } /** - * A type-guard check for context menu application commands. + * A type guard check for context menu application commands. * * @param interaction - The interaction to check against * @returns A boolean that indicates if the interaction is a context menu application command diff --git a/deno/utils/v9.ts b/deno/utils/v9.ts index 58ebc6f5..a328a27a 100644 --- a/deno/utils/v9.ts +++ b/deno/utils/v9.ts @@ -15,13 +15,14 @@ import type { APIMessageComponentGuildInteraction, APIMessageComponentInteraction, APIMessageComponentSelectMenuInteraction, + APIModalSubmitInteraction, } from '../payloads/v9/mod.ts'; import { ApplicationCommandType, ButtonStyle, ComponentType, InteractionType } from '../payloads/v9/mod.ts'; // Interactions /** - * A type-guard check for DM interactions + * A type guard check for DM interactions * * @param interaction - The interaction to check against * @returns A boolean that indicates if the interaction was received in a DM channel @@ -31,7 +32,7 @@ export function isDMInteraction(interaction: APIInteraction): interaction is API } /** - * A type-guard check for guild interactions + * A type guard check for guild interactions * * @param interaction - The interaction to check against * @returns A boolean that indicates if the interaction was received in a guild @@ -43,7 +44,7 @@ export function isGuildInteraction(interaction: APIInteraction): interaction is // ApplicationCommandInteractions /** - * A type-guard check for DM application command interactions + * A type guard check for DM application command interactions * * @param interaction - The application command interaction to check against * @returns A boolean that indicates if the application command interaction was received in a DM channel @@ -55,7 +56,7 @@ export function isApplicationCommandDMInteraction( } /** - * A type-guard check for guild application command interactions + * A type guard check for guild application command interactions * * @param interaction - The interaction to check against * @returns A boolean that indicates if the application command interaction was received in a guild @@ -69,7 +70,7 @@ export function isApplicationCommandGuildInteraction( // MessageComponentInteractions /** - * A type-guard check for DM message component interactions + * A type guard check for DM message component interactions * * @param interaction - The message component interaction to check against * @returns A boolean that indicates if the message component interaction was received in a DM channel @@ -81,7 +82,7 @@ export function isMessageComponentDMInteraction( } /** - * A type-guard check for guild message component interactions + * A type guard check for guild message component interactions * * @param interaction - The interaction to check against * @returns A boolean that indicates if the message component interaction was received in a guild @@ -95,7 +96,7 @@ export function isMessageComponentGuildInteraction( // Buttons /** - * A type-guard check for buttons that have a `url` attached to them. + * A type guard check for buttons that have a `url` attached to them. * * @param component - The button to check against * @returns A boolean that indicates if the button has a `url` attached to it @@ -105,7 +106,7 @@ export function isLinkButton(component: APIButtonComponent): component is APIBut } /** - * A type-guard check for buttons that have a `custom_id` attached to them. + * A type guard check for buttons that have a `custom_id` attached to them. * * @param component - The button to check against * @returns A boolean that indicates if the button has a `custom_id` attached to it @@ -114,10 +115,22 @@ export function isInteractionButton(component: APIButtonComponent): component is return ![ButtonStyle.Link, ButtonStyle.Premium].includes(component.style); } +// Modal + +/** + * A type guard check for modals submit interactions + * + * @param interaction - The interaction to check against + * @returns A boolean that indicates if the interaction is a modal submission + */ +export function isModalSubmitInteraction(interaction: APIInteraction): interaction is APIModalSubmitInteraction { + return interaction.type === InteractionType.ModalSubmit; +} + // Message Components /** - * A type-guard check for message component interactions + * A type guard check for message component interactions * * @param interaction - The interaction to check against * @returns A boolean that indicates if the interaction is a message component @@ -129,7 +142,7 @@ export function isMessageComponentInteraction( } /** - * A type-guard check for button message component interactions + * A type guard check for button message component interactions * * @param interaction - The message component interaction to check against * @returns A boolean that indicates if the message component is a button @@ -141,7 +154,7 @@ export function isMessageComponentButtonInteraction( } /** - * A type-guard check for select menu message component interactions + * A type guard check for select menu message component interactions * * @param interaction - The message component interaction to check against * @returns A boolean that indicates if the message component is a select menu @@ -161,7 +174,7 @@ export function isMessageComponentSelectMenuInteraction( // Application Commands /** - * A type-guard check for chat input application commands. + * A type guard check for chat input application commands. * * @param interaction - The interaction to check against * @returns A boolean that indicates if the interaction is a chat input application command @@ -173,7 +186,7 @@ export function isChatInputApplicationCommandInteraction( } /** - * A type-guard check for context menu application commands. + * A type guard check for context menu application commands. * * @param interaction - The interaction to check against * @returns A boolean that indicates if the interaction is a context menu application command diff --git a/utils/v10.ts b/utils/v10.ts index ce47351b..0efce63a 100644 --- a/utils/v10.ts +++ b/utils/v10.ts @@ -15,13 +15,14 @@ import type { APIMessageComponentGuildInteraction, APIMessageComponentInteraction, APIMessageComponentSelectMenuInteraction, + APIModalSubmitInteraction, } from '../payloads/v10/index'; import { ApplicationCommandType, ButtonStyle, ComponentType, InteractionType } from '../payloads/v10/index'; // Interactions /** - * A type-guard check for DM interactions + * A type guard check for DM interactions * * @param interaction - The interaction to check against * @returns A boolean that indicates if the interaction was received in a DM channel @@ -31,7 +32,7 @@ export function isDMInteraction(interaction: APIInteraction): interaction is API } /** - * A type-guard check for guild interactions + * A type guard check for guild interactions * * @param interaction - The interaction to check against * @returns A boolean that indicates if the interaction was received in a guild @@ -43,7 +44,7 @@ export function isGuildInteraction(interaction: APIInteraction): interaction is // ApplicationCommandInteractions /** - * A type-guard check for DM application command interactions + * A type guard check for DM application command interactions * * @param interaction - The application command interaction to check against * @returns A boolean that indicates if the application command interaction was received in a DM channel @@ -55,7 +56,7 @@ export function isApplicationCommandDMInteraction( } /** - * A type-guard check for guild application command interactions + * A type guard check for guild application command interactions * * @param interaction - The interaction to check against * @returns A boolean that indicates if the application command interaction was received in a guild @@ -69,7 +70,7 @@ export function isApplicationCommandGuildInteraction( // MessageComponentInteractions /** - * A type-guard check for DM message component interactions + * A type guard check for DM message component interactions * * @param interaction - The message component interaction to check against * @returns A boolean that indicates if the message component interaction was received in a DM channel @@ -81,7 +82,7 @@ export function isMessageComponentDMInteraction( } /** - * A type-guard check for guild message component interactions + * A type guard check for guild message component interactions * * @param interaction - The interaction to check against * @returns A boolean that indicates if the message component interaction was received in a guild @@ -95,7 +96,7 @@ export function isMessageComponentGuildInteraction( // Buttons /** - * A type-guard check for buttons that have a `url` attached to them. + * A type guard check for buttons that have a `url` attached to them. * * @param component - The button to check against * @returns A boolean that indicates if the button has a `url` attached to it @@ -105,7 +106,7 @@ export function isLinkButton(component: APIButtonComponent): component is APIBut } /** - * A type-guard check for buttons that have a `custom_id` attached to them. + * A type guard check for buttons that have a `custom_id` attached to them. * * @param component - The button to check against * @returns A boolean that indicates if the button has a `custom_id` attached to it @@ -114,10 +115,22 @@ export function isInteractionButton(component: APIButtonComponent): component is return ![ButtonStyle.Link, ButtonStyle.Premium].includes(component.style); } +// Modal + +/** + * A type guard check for modals submit interactions + * + * @param interaction - The interaction to check against + * @returns A boolean that indicates if the interaction is a modal submission + */ +export function isModalSubmitInteraction(interaction: APIInteraction): interaction is APIModalSubmitInteraction { + return interaction.type === InteractionType.ModalSubmit; +} + // Message Components /** - * A type-guard check for message component interactions + * A type guard check for message component interactions * * @param interaction - The interaction to check against * @returns A boolean that indicates if the interaction is a message component @@ -129,7 +142,7 @@ export function isMessageComponentInteraction( } /** - * A type-guard check for button message component interactions + * A type guard check for button message component interactions * * @param interaction - The message component interaction to check against * @returns A boolean that indicates if the message component is a button @@ -141,7 +154,7 @@ export function isMessageComponentButtonInteraction( } /** - * A type-guard check for select menu message component interactions + * A type guard check for select menu message component interactions * * @param interaction - The message component interaction to check against * @returns A boolean that indicates if the message component is a select menu @@ -161,7 +174,7 @@ export function isMessageComponentSelectMenuInteraction( // Application Commands /** - * A type-guard check for chat input application commands. + * A type guard check for chat input application commands. * * @param interaction - The interaction to check against * @returns A boolean that indicates if the interaction is a chat input application command @@ -173,7 +186,7 @@ export function isChatInputApplicationCommandInteraction( } /** - * A type-guard check for context menu application commands. + * A type guard check for context menu application commands. * * @param interaction - The interaction to check against * @returns A boolean that indicates if the interaction is a context menu application command diff --git a/utils/v9.ts b/utils/v9.ts index b21003ef..ed166193 100644 --- a/utils/v9.ts +++ b/utils/v9.ts @@ -15,13 +15,14 @@ import type { APIMessageComponentGuildInteraction, APIMessageComponentInteraction, APIMessageComponentSelectMenuInteraction, + APIModalSubmitInteraction, } from '../payloads/v9/index'; import { ApplicationCommandType, ButtonStyle, ComponentType, InteractionType } from '../payloads/v9/index'; // Interactions /** - * A type-guard check for DM interactions + * A type guard check for DM interactions * * @param interaction - The interaction to check against * @returns A boolean that indicates if the interaction was received in a DM channel @@ -31,7 +32,7 @@ export function isDMInteraction(interaction: APIInteraction): interaction is API } /** - * A type-guard check for guild interactions + * A type guard check for guild interactions * * @param interaction - The interaction to check against * @returns A boolean that indicates if the interaction was received in a guild @@ -43,7 +44,7 @@ export function isGuildInteraction(interaction: APIInteraction): interaction is // ApplicationCommandInteractions /** - * A type-guard check for DM application command interactions + * A type guard check for DM application command interactions * * @param interaction - The application command interaction to check against * @returns A boolean that indicates if the application command interaction was received in a DM channel @@ -55,7 +56,7 @@ export function isApplicationCommandDMInteraction( } /** - * A type-guard check for guild application command interactions + * A type guard check for guild application command interactions * * @param interaction - The interaction to check against * @returns A boolean that indicates if the application command interaction was received in a guild @@ -69,7 +70,7 @@ export function isApplicationCommandGuildInteraction( // MessageComponentInteractions /** - * A type-guard check for DM message component interactions + * A type guard check for DM message component interactions * * @param interaction - The message component interaction to check against * @returns A boolean that indicates if the message component interaction was received in a DM channel @@ -81,7 +82,7 @@ export function isMessageComponentDMInteraction( } /** - * A type-guard check for guild message component interactions + * A type guard check for guild message component interactions * * @param interaction - The interaction to check against * @returns A boolean that indicates if the message component interaction was received in a guild @@ -95,7 +96,7 @@ export function isMessageComponentGuildInteraction( // Buttons /** - * A type-guard check for buttons that have a `url` attached to them. + * A type guard check for buttons that have a `url` attached to them. * * @param component - The button to check against * @returns A boolean that indicates if the button has a `url` attached to it @@ -105,7 +106,7 @@ export function isLinkButton(component: APIButtonComponent): component is APIBut } /** - * A type-guard check for buttons that have a `custom_id` attached to them. + * A type guard check for buttons that have a `custom_id` attached to them. * * @param component - The button to check against * @returns A boolean that indicates if the button has a `custom_id` attached to it @@ -114,10 +115,22 @@ export function isInteractionButton(component: APIButtonComponent): component is return ![ButtonStyle.Link, ButtonStyle.Premium].includes(component.style); } +// Modal + +/** + * A type guard check for modals submit interactions + * + * @param interaction - The interaction to check against + * @returns A boolean that indicates if the interaction is a modal submission + */ +export function isModalSubmitInteraction(interaction: APIInteraction): interaction is APIModalSubmitInteraction { + return interaction.type === InteractionType.ModalSubmit; +} + // Message Components /** - * A type-guard check for message component interactions + * A type guard check for message component interactions * * @param interaction - The interaction to check against * @returns A boolean that indicates if the interaction is a message component @@ -129,7 +142,7 @@ export function isMessageComponentInteraction( } /** - * A type-guard check for button message component interactions + * A type guard check for button message component interactions * * @param interaction - The message component interaction to check against * @returns A boolean that indicates if the message component is a button @@ -141,7 +154,7 @@ export function isMessageComponentButtonInteraction( } /** - * A type-guard check for select menu message component interactions + * A type guard check for select menu message component interactions * * @param interaction - The message component interaction to check against * @returns A boolean that indicates if the message component is a select menu @@ -161,7 +174,7 @@ export function isMessageComponentSelectMenuInteraction( // Application Commands /** - * A type-guard check for chat input application commands. + * A type guard check for chat input application commands. * * @param interaction - The interaction to check against * @returns A boolean that indicates if the interaction is a chat input application command @@ -173,7 +186,7 @@ export function isChatInputApplicationCommandInteraction( } /** - * A type-guard check for context menu application commands. + * A type guard check for context menu application commands. * * @param interaction - The interaction to check against * @returns A boolean that indicates if the interaction is a context menu application command