Update modals

This commit is contained in:
Tarrgon
2026-05-19 12:14:19 -04:00
parent 7e5ec68f7e
commit 13251468b1
7 changed files with 68 additions and 96 deletions
+43
View File
@@ -0,0 +1,43 @@
import { LabelBuilder, StringSelectMenuBuilder, StringSelectMenuOptionBuilder, TextInputBuilder, TextInputStyle } from 'discord.js';
export function createTextInput(customId: string, labelTitle: string, description: string | null, required: boolean, style: TextInputStyle, maxLength: number | null, minLength: number | null): LabelBuilder {
const input = new TextInputBuilder()
.setCustomId(customId)
.setStyle(style)
.setRequired(required);
if (maxLength !== null) input.setMaxLength(maxLength);
if (minLength !== null) input.setMinLength(minLength);
const label = new LabelBuilder()
.setLabel(labelTitle);
if (description !== null) label.setDescription(description);
label.setTextInputComponent(input);
return label;
}
export function createYesNoMenu(customId: string, labelTitle: string, description: string | null, defaultYes: boolean): LabelBuilder {
const yesNoMenu = new StringSelectMenuBuilder()
.setCustomId(customId)
.addOptions(
new StringSelectMenuOptionBuilder()
.setLabel('Yes')
.setDefault(defaultYes)
.setValue('yes'),
new StringSelectMenuOptionBuilder()
.setLabel('No')
.setDefault(!defaultYes)
.setValue('no')
);
const yesNoLabel = new LabelBuilder()
.setLabel(labelTitle)
.setStringSelectMenuComponent(yesNoMenu);
if (description !== null) yesNoLabel.setDescription(description);
return yesNoLabel;
}