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

View File

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