From 0e53c17b381ef86ef7b9a71c59f01175d13b010d Mon Sep 17 00:00:00 2001 From: Snazzah Date: Sat, 24 Jan 2026 19:15:30 -0500 Subject: [PATCH] feat: support checkboxes in modals --- src/constants.ts | 74 ++++++++++++++++++- .../interfaces/modalInteractionContext.ts | 2 +- 2 files changed, 72 insertions(+), 4 deletions(-) diff --git a/src/constants.ts b/src/constants.ts index bad87435..283b65c3 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -1059,7 +1059,13 @@ export enum ComponentType { /** A label component. */ LABEL = 18, /** A file upload component. */ - FILE_UPLOAD = 19 + FILE_UPLOAD = 19, + /** A component to group radio options in. */ + RADIO_GROUP = 21, + /** A component to group checkboxes in. */ + CHECKBOX_GROUP = 22, + /** A checkbox component. */ + CHECKBOX = 23 } /** The types of component button styles. */ @@ -1206,7 +1212,13 @@ export interface LabelComponent { type: ComponentType.LABEL; label: string; description?: string; - component: AnySelectComponent | ComponentFileUpload | Omit; + component: + | AnySelectComponent + | ComponentFileUpload + | RadioGroupComponent + | CheckboxGroupComponent + | CheckboxComponent + | Omit; } /** Any component. */ @@ -1222,7 +1234,10 @@ export type AnyComponent = | FileComponent | ContainerComponent | LabelComponent - | ComponentFileUpload; + | ComponentFileUpload + | RadioGroupComponent + | CheckboxGroupComponent + | CheckboxComponent; /** A row of components. */ export interface ComponentActionRow { @@ -1422,6 +1437,59 @@ export interface ComponentFileUpload { required?: boolean; } +export interface RadioGroupComponent { + /** The type of component to use. */ + type: ComponentType.RADIO_GROUP; + /** Optional component identifier */ + id?: number; + /** The identifier of the of the input. */ + custom_id: string; + /** Th eoptions for this group. */ + options: RadioGroupOption[]; + /** Whether this component is required to be filled. */ + required?: boolean; +} + +export interface RadioGroupOption { + value: string; + label: string; + description?: string; + default?: boolean; +} + +export interface CheckboxGroupComponent { + /** The type of component to use. */ + type: ComponentType.CHECKBOX_GROUP; + /** Optional component identifier */ + id?: number; + /** The identifier of the of the input. */ + custom_id: string; + options: CheckboxGroupOption[]; + /** The minimum options to be checked. */ + min_values?: number; + /** The maximum options to be checked. */ + max_values?: number; + required?: boolean; +} + +export interface CheckboxGroupOption { + value: string; + label: string; + description?: string; + default?: boolean; +} + +export interface CheckboxComponent { + /** The type of component to use. */ + type: ComponentType.CHECKBOX; + /** Optional component identifier */ + id?: number; + /** The identifier of the of the input. */ + custom_id: string; + /** The default state of this checkbox. */ + default?: boolean; +} + /** @hidden */ export interface ComponentSelectResponse { type: diff --git a/src/structures/interfaces/modalInteractionContext.ts b/src/structures/interfaces/modalInteractionContext.ts index a591e117..65f044d2 100644 --- a/src/structures/interfaces/modalInteractionContext.ts +++ b/src/structures/interfaces/modalInteractionContext.ts @@ -24,7 +24,7 @@ export class ModalInteractionContext< readonly message?: Message; /** The values defined in the modal submission. */ - readonly values: { [key: string]: string | string[] }; + readonly values: { [key: string]: string | string[] | boolean }; /** * @param creator The instantiating creator.