diff --git a/components/runtime/src/ts/discord/index.ts b/components/runtime/src/ts/discord/index.ts index 1a9a411..d020a51 100644 --- a/components/runtime/src/ts/discord/index.ts +++ b/components/runtime/src/ts/discord/index.ts @@ -12,3 +12,4 @@ export * from './permissions'; export * from './snowflake'; export * from './webhook'; export * from '../generated/discord/index'; +export * from './modal'; \ No newline at end of file diff --git a/components/runtime/src/ts/discord/interaction.ts b/components/runtime/src/ts/discord/interaction.ts index 3f6d389..4554df9 100644 --- a/components/runtime/src/ts/discord/interaction.ts +++ b/components/runtime/src/ts/discord/interaction.ts @@ -18,6 +18,7 @@ import { Member } from './member'; import { Message } from './message'; import { GuildChannel } from './channel'; import { User } from './user'; +import { type IModalFields, Modal } from './modal'; /** * Base interaction class, this class should be considered UNSTABLE and may change a lot in the future. @@ -236,7 +237,7 @@ export class ComponentInteraction extends Interaction { * * You have to acknowledge the interaction within 3 seconds, and it can only be done once. */ - async ackWithModal(modal: IModalFields) { + async ackWithModal(modal: IModalFields | Modal) { this.setCallbackSent(); return OpWrappers.interactionCallback({ @@ -252,13 +253,6 @@ export class ComponentInteraction extends Interaction { } } -export interface IModalFields { - title: string, - customId: string, - components: IComponent[], -} - - export class ModalSubmitInteraction extends Interaction { customIdRaw: string; channelId: string; diff --git a/components/runtime/src/ts/discord/modal.ts b/components/runtime/src/ts/discord/modal.ts new file mode 100644 index 0000000..2cb1ddc --- /dev/null +++ b/components/runtime/src/ts/discord/modal.ts @@ -0,0 +1,25 @@ +import { IComponent } from '../generated/discord/index'; +import { encodeInteractionCustomId } from './interaction'; + +export interface IModalFields { + title: string, + customId: string, + components: IComponent[], +} + +export interface IModal extends IModalFields { + kind: string +} + +export class Modal implements IModal { + kind = "Modal" + customId: string; + title: string; + components: IComponent[]; + + constructor(title: string, components: IComponent[], name: string, data?: any) { + this.customId = encodeInteractionCustomId(name, data ?? null) + this.title = title; + this.components = components; + } +} \ No newline at end of file