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
+2 -1
View File
@@ -12,7 +12,9 @@ export * from './event-log-utils';
export * from './file-utils';
export * from './github-user-utils';
export * from './interaction-utils';
export * from './message-matcher-regex';
export * from './message-utils';
export * from './modal-utils';
export * from './ms-to-human';
export * from './name-sync';
export * from './note-utils';
@@ -20,7 +22,6 @@ export * from './oauth2';
export * from './private-help-utils';
export * from './record-utils';
export * from './refresh-commands';
export * from './message-matcher-regex';
export * from './string-utils';
export * from './ticket-events';
export * from './ticket-utils';
+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;
}
+5 -41
View File
@@ -1,5 +1,6 @@
import { ActionRowBuilder, ButtonBuilder, ButtonStyle, ChannelType, ChatInputCommandInteraction, Client, Guild, GuildMember, LabelBuilder, ModalBuilder, PrivateThreadChannel, StringSelectMenuBuilder, StringSelectMenuOptionBuilder, TextChannel, TextInputBuilder, TextInputStyle, ThreadAutoArchiveDuration, ThreadChannel, UserContextMenuCommandInteraction } from 'discord.js';
import { ActionRowBuilder, ButtonBuilder, ButtonStyle, ChannelType, ChatInputCommandInteraction, Client, Guild, GuildMember, ModalBuilder, PrivateThreadChannel, TextChannel, TextInputStyle, ThreadAutoArchiveDuration, ThreadChannel, UserContextMenuCommandInteraction } from 'discord.js';
import { Database } from '../shared/Database';
import { createTextInput, createYesNoMenu } from './modal-utils';
export async function closeOldTickets(client: Client) {
for (const ticket of await Database.getAllOpenPrivateHelpTickets()) {
@@ -89,46 +90,9 @@ export async function openModTicketModal(interaction: UserContextMenuCommandInte
.setCustomId(`open-mod-ticket_${member.id}`)
.setTitle(`Opening A Mod Ticket With ${member.displayName}`);
const titleInput = new TextInputBuilder()
.setCustomId('title')
.setMaxLength(100)
.setStyle(TextInputStyle.Short)
.setRequired(false);
const titleLabel = new LabelBuilder()
.setLabel('Title')
.setDescription(`The name of the thread. Defaults to "Mod Ticket For ${member.displayName}" if left empty`)
.setTextInputComponent(titleInput);
const initialMessageInput = new TextInputBuilder()
.setCustomId('initial-message')
.setMaxLength(1800)
.setStyle(TextInputStyle.Paragraph)
.setRequired(false);
const initialMessageLabel = new LabelBuilder()
.setLabel('Inital Message')
.setDescription('The inital message sent in the thread')
.setTextInputComponent(initialMessageInput);
const yesNoMenu = new StringSelectMenuBuilder()
.setCustomId('auto-join-thread')
.setRequired(false)
.addOptions(
new StringSelectMenuOptionBuilder()
.setLabel('Yes')
.setDefault(true)
.setValue('yes'),
new StringSelectMenuOptionBuilder()
.setLabel('No')
.setDefault(false)
.setValue('no')
);
const autoJoinLabel = new LabelBuilder()
.setLabel('Auto Join Thread')
.setDescription('Whether or not to join you to the thread. Selecting no will not notify you of messages sent!')
.setStringSelectMenuComponent(yesNoMenu);
const titleLabel = createTextInput('title', 'Title', `The name of the thread. Defaults to "Mod Ticket For ${member.displayName}" if left empty`, false, TextInputStyle.Short, 100, null);
const initialMessageLabel = createTextInput('initial-message', 'Inital Message', 'The inital message sent in the thread', false, TextInputStyle.Paragraph, 1800, null);
const autoJoinLabel = createYesNoMenu('auto-join-thread', 'Auto Join Thread', 'Whether or not to join you to the thread. Selecting no will not notify you of messages sent!', true);
modal.addLabelComponents(titleLabel, initialMessageLabel, autoJoinLabel);