From e350f74d2009869e6f44b463e09f3ad00a73d494 Mon Sep 17 00:00:00 2001 From: gc <30398469+gc@users.noreply.github.com> Date: Tue, 6 Aug 2024 22:17:36 +1000 Subject: [PATCH] commit --- src/mahoji/commands/bs.ts | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/src/mahoji/commands/bs.ts b/src/mahoji/commands/bs.ts index d3f53ab971..e742577565 100644 --- a/src/mahoji/commands/bs.ts +++ b/src/mahoji/commands/bs.ts @@ -1,5 +1,12 @@ import type { CommandRunOptions } from '@oldschoolgg/toolkit'; -import { ApplicationCommandOptionType } from 'discord.js'; +import { + ActionRowBuilder, + ApplicationCommandOptionType, + type ModalActionRowComponentBuilder, + ModalBuilder, + TextInputBuilder, + TextInputStyle +} from 'discord.js'; import type { OSBMahojiCommand } from '../lib/util'; import { bankCommand } from './bank'; @@ -31,6 +38,36 @@ export const bsCommand: OSBMahojiCommand = { format?: BankFormat; }> ) => { + // Create the modal + const modal = new ModalBuilder().setCustomId('myModal').setTitle('My Modal'); + + // Add components to modal + + // Create the text input components + const favoriteColorInput = new TextInputBuilder() + .setCustomId('favoriteColorInput') + // The label is the prompt the user sees for this input + .setLabel("What's your favorite color?") + // Short means only a single line of text + .setStyle(TextInputStyle.Short); + + const hobbiesInput = new TextInputBuilder() + .setCustomId('hobbiesInput') + .setLabel("What's some of your favorite hobbies?") + // Paragraph means multiple lines of text. + .setStyle(TextInputStyle.Paragraph); + + // An action row only holds one text input, + // so you need one action row per text input. + const firstActionRow = new ActionRowBuilder().addComponents(favoriteColorInput); + const secondActionRow = new ActionRowBuilder().addComponents(hobbiesInput); + + // Add inputs to the modal + modal.addComponents(firstActionRow, secondActionRow); + + // Show the modal to the user + await options.interaction.showModal(modal); + const res = await bankCommand.run(options); return res; }