modal

const { SlashCommandBuilder, EmbedBuilder, ActionRowBuilder, Events, ModalBuilder, TextInputBuilder, TextInputStyle } = require('discord.js');
const Client = require('../Constants/Client.js');
module.exports = {
data: new SlashCommandBuilder()
.setName('modal')
.setDescription('modal'),

async execute(interaction) {

const filter = (interaction) => interaction.customId === 'modal';
const modal = new ModalBuilder()
.setCustomId('modal')
.setTitle('My Modal');

// Add components to modal

// Create the text input components
const favoriteColorInput = new TextInputBuilder()
.setCustomId('favoriteColorInput')
// The label is the prompt the user sees for this input
.setLabel("What's your favorite color?")
// Short means only a single line of text
.setStyle(TextInputStyle.Short);

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

// An action row only holds one text input,
// so you need one action row per text input.
const firstActionRow = new ActionRowBuilder().addComponents(favoriteColorInput);
const secondActionRow = new ActionRowBuilder().addComponents(hobbiesInput);

// Add inputs to the modal
modal.addComponents(firstActionRow, secondActionRow);

// Show the modal to the user
await interaction.showModal(modal);


interaction.awaitModalSubmit({ filter })
.then(async interaction => await interaction.followUp('submitted patrol log'))
.catch(console.error);
}};
const { SlashCommandBuilder, EmbedBuilder, ActionRowBuilder, Events, ModalBuilder, TextInputBuilder, TextInputStyle } = require('discord.js');
const Client = require('../Constants/Client.js');
module.exports = {
data: new SlashCommandBuilder()
.setName('modal')
.setDescription('modal'),

async execute(interaction) {

const filter = (interaction) => interaction.customId === 'modal';
const modal = new ModalBuilder()
.setCustomId('modal')
.setTitle('My Modal');

// Add components to modal

// Create the text input components
const favoriteColorInput = new TextInputBuilder()
.setCustomId('favoriteColorInput')
// The label is the prompt the user sees for this input
.setLabel("What's your favorite color?")
// Short means only a single line of text
.setStyle(TextInputStyle.Short);

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

// An action row only holds one text input,
// so you need one action row per text input.
const firstActionRow = new ActionRowBuilder().addComponents(favoriteColorInput);
const secondActionRow = new ActionRowBuilder().addComponents(hobbiesInput);

// Add inputs to the modal
modal.addComponents(firstActionRow, secondActionRow);

// Show the modal to the user
await interaction.showModal(modal);


interaction.awaitModalSubmit({ filter })
.then(async interaction => await interaction.followUp('submitted patrol log'))
.catch(console.error);
}};
the momment I run the command it responds with submitted patrol log
14 Replies
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
MrMythical
MrMythical3y ago
You're saying when the slash command is run, the followUp immediately runs?
JollyJohn
JollyJohnOP3y ago
Yes
MrMythical
MrMythical3y ago
Could you please log interaction Send the output in a bin
JollyJohn
JollyJohnOP3y ago
Pastebin
Error [InvalidType]: Supplied time is not a number. at ChatInput...
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
MrMythical
MrMythical3y ago
So you're receiving an error Because you didn't specify a time
JollyJohn
JollyJohnOP3y ago
but why would it still be followup immediately?
JollyJohn
JollyJohnOP3y ago
Pastebin
ChatInputCommandInteraction { type: 2, id: '1048261385001373756',...
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Pastebin
const { SlashCommandBuilder, EmbedBuilder, ActionRowBuilder, Events...
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
MrMythical
MrMythical3y ago
Because the promise seems to be resolved with the error for some reason
JollyJohn
JollyJohnOP3y ago
ye i added time and now i get this stuff i logged interaction for u'
MrMythical
MrMythical3y ago
Ok don't log interaction anymore
JollyJohn
JollyJohnOP3y ago
JollyJohn
JollyJohnOP3y ago
ill try reply now it works thanks i get this now
JollyJohn
JollyJohnOP3y ago
https://pastebin.com/a6HWfGiH
TypeError: Cannot read properties of undefined (reading 'getTextInputValue')
at Object.execute (/Users/oerston25/Desktop/test-bot/commands/modal.js:62:51)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Client.<anonymous> (/Users/oerston25/Desktop/test-bot/index.js:73:5)
node:events:491
TypeError: Cannot read properties of undefined (reading 'getTextInputValue')
at Object.execute (/Users/oerston25/Desktop/test-bot/commands/modal.js:62:51)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Client.<anonymous> (/Users/oerston25/Desktop/test-bot/index.js:73:5)
node:events:491
throw er; // Unhandled 'error' event
^

Error [InteractionAlreadyReplied]: The reply to this interaction has already been sent or deferred.
at ChatInputCommandInteraction.reply (/Users/oerston25/Desktop/test-bot/node_modules/discord.js/src/structures/interfaces/InteractionResponses.js:102:46)
at Client.<anonymous> (/Users/oerston25/Desktop/test-bot/index.js:76:23)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
Emitted 'error' event on Client instance at:
at emitUnhandledRejectionOrErr (node:events:394:10)
at process.processTicksAndRejections (node:internal/process/task_queues:84:21) {
code: 'InteractionAlreadyReplied'
throw er; // Unhandled 'error' event
^

Error [InteractionAlreadyReplied]: The reply to this interaction has already been sent or deferred.
at ChatInputCommandInteraction.reply (/Users/oerston25/Desktop/test-bot/node_modules/discord.js/src/structures/interfaces/InteractionResponses.js:102:46)
at Client.<anonymous> (/Users/oerston25/Desktop/test-bot/index.js:76:23)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
Emitted 'error' event on Client instance at:
at emitUnhandledRejectionOrErr (node:events:394:10)
at process.processTicksAndRejections (node:internal/process/task_queues:84:21) {
code: 'InteractionAlreadyReplied'
Pastebin
const { SlashCommandBuilder, EmbedBuilder, ActionRowBuilder, Events...
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Want results from more Discord servers?
Add your server