Skip to content

Commit

Permalink
commit
Browse files Browse the repository at this point in the history
  • Loading branch information
gc committed Aug 6, 2024
1 parent 99adf76 commit e350f74
Showing 1 changed file with 38 additions and 1 deletion.
39 changes: 38 additions & 1 deletion src/mahoji/commands/bs.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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<ModalActionRowComponentBuilder>().addComponents(favoriteColorInput);
const secondActionRow = new ActionRowBuilder<ModalActionRowComponentBuilder>().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;
}
Expand Down

0 comments on commit e350f74

Please sign in to comment.