feat: refactor prefix settings modal to use plain objects for improved structure and localization
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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({
|
||||
|
||||
Reference in New Issue
Block a user