𝙎𝙩𝙖𝙠𝙪™
𝙎𝙩𝙖𝙠𝙪™
DIAdiscord.js - Imagine an app
Created by 𝙎𝙩𝙖𝙠𝙪™ on 6/13/2024 in #djs-questions
Modal Submit not Working
Can someone help me, I can't submit a Modal I can open it, but it won't even get to the submit function for some reason packages : :djs: @discordjs/builders: 1.8.2 :djs: discord.js: 14.15.3 command :
// modal.js
'use strict';

import { SlashCommandBuilder, ActionRowBuilder, ModalBuilder, TextInputBuilder } from '@discordjs/builders';
import { PermissionFlagsBits, TextInputStyle } from 'discord.js';

export default {
data: new SlashCommandBuilder()
.setName('modal')
.setDescription('test modal')
.setDefaultMemberPermissions(PermissionFlagsBits.UseApplicationCommands),

/**
* @param {import('discord.js').Client} client
* @param {import('discord.js').Interaction} interaction
*/
async execute(client, interaction) {
const modal = new ModalBuilder().setCustomId('myModal').setTitle('My Modal');

const favoriteColorInput = new TextInputBuilder()
.setCustomId('favoriteColorInput')
.setLabel("What's your favorite color?")
.setStyle(TextInputStyle.Short);

const hobbiesInput = new TextInputBuilder()
.setCustomId('hobbiesInput')
.setLabel("What's some of your favorite hobbies?")
.setStyle(TextInputStyle.Paragraph);

const firstActionRow = new ActionRowBuilder().addComponents(favoriteColorInput);
const secondActionRow = new ActionRowBuilder().addComponents(hobbiesInput);

modal.addComponents(firstActionRow, secondActionRow);

await interaction.showModal(modal);
},

/**
* @param {import('discord.js').Client} client
* @param {import('discord.js').Interaction} interaction
*/
async submit(client, interaction) {
console.log('modalSubmit');
},
};
// modal.js
'use strict';

import { SlashCommandBuilder, ActionRowBuilder, ModalBuilder, TextInputBuilder } from '@discordjs/builders';
import { PermissionFlagsBits, TextInputStyle } from 'discord.js';

export default {
data: new SlashCommandBuilder()
.setName('modal')
.setDescription('test modal')
.setDefaultMemberPermissions(PermissionFlagsBits.UseApplicationCommands),

/**
* @param {import('discord.js').Client} client
* @param {import('discord.js').Interaction} interaction
*/
async execute(client, interaction) {
const modal = new ModalBuilder().setCustomId('myModal').setTitle('My Modal');

const favoriteColorInput = new TextInputBuilder()
.setCustomId('favoriteColorInput')
.setLabel("What's your favorite color?")
.setStyle(TextInputStyle.Short);

const hobbiesInput = new TextInputBuilder()
.setCustomId('hobbiesInput')
.setLabel("What's some of your favorite hobbies?")
.setStyle(TextInputStyle.Paragraph);

const firstActionRow = new ActionRowBuilder().addComponents(favoriteColorInput);
const secondActionRow = new ActionRowBuilder().addComponents(hobbiesInput);

modal.addComponents(firstActionRow, secondActionRow);

await interaction.showModal(modal);
},

/**
* @param {import('discord.js').Client} client
* @param {import('discord.js').Interaction} interaction
*/
async submit(client, interaction) {
console.log('modalSubmit');
},
};
10 replies