feat: refactor prefix settings modal to use plain objects for improved structure and localization

This commit is contained in:
2025-10-03 22:39:02 -05:00
parent 1bbb273bc9
commit 204b86e706
2 changed files with 20 additions and 13 deletions

View File

@@ -1,22 +1,29 @@
import type {ButtonInteraction} from "discord.js";
import { ActionRowBuilder, ModalBuilder, TextInputBuilder, TextInputStyle } from 'discord.js';
import { ComponentType, TextInputStyle } from 'discord-api-types/v10';
import type { Button } from '../../core/types/components';
import type Amayo from '../../core/client';
export default {
customId: "prefixsettings",
run: async (interaction: ButtonInteraction, client: Amayo) => {
const modal = new ModalBuilder()
.setCustomId('prefixsettingsmodal')
.setTitle('Prefix');
const prefixInput = new TextInputBuilder()
.setCustomId('prefixInput')
.setLabel("Change Prefix")
.setStyle(TextInputStyle.Short);
const secondActionRow = new ActionRowBuilder<TextInputBuilder>().addComponents(prefixInput);
modal.addComponents(secondActionRow);
const modal = {
title: 'Cambiar Prefix',
customId: 'prefixsettingsmodal',
components: [
{
type: ComponentType.Label,
label: 'Nuevo Prefix',
component: {
type: ComponentType.TextInput,
customId: 'prefixInput',
style: TextInputStyle.Short,
required: true,
placeholder: 'Ej: !, ?, $',
maxLength: 5
},
},
],
} as const;
await interaction.showModal(modal);
}

View File

@@ -6,7 +6,7 @@ import type Amayo from '../../core/client';
export default {
customId: "prefixsettingsmodal",
run: async (interaction: ModalSubmitInteraction, client: Amayo) => {
const newPrefix = interaction.fields.getTextInputValue("prefixInput");
const newPrefix = interaction.components.getTextInputValue("prefixInput");
if (!newPrefix || newPrefix.length > 10) {
return interaction.reply({