I am making a command for my bot that when you the /createannouncement it shows a modal that you can put in the information for. it keeps coming up with an error and also in discord saying “The Application Did Not Respond”
this code worked before when i only had it replying to the message and using emphemeral idk why modals hate me but they do,
I followed the discordjs.guide websites guide on it but it just errors and idk why
This Is the code that i have:
const { SlashCommandBuilder, EmbedBuilder, ModalBuilder, ActionRowBuilder, TextInputBuilder, TextInputStyle} = require('discord.js');
module.exports = {
data: new SlashCommandBuilder()
.setName('createannouncement')
.setDescription('Creates An Announcement')
.addChannelOption(option =>
option
.setName('announcement-channel')
.setDescription('The Channel to Send the Announcement to')),
async execute(interaction) {
const channel = interaction.options.getChannel('announcement-channel');
const announcementModal = new ModalBuilder()
.setCustomId('announcementCreator')
.setTitle('Announcement Creator');
const announcementTitleInput = new TextInputBuilder()
.setCustomId('announcementTitleInput')
.setLabel('Announcement Title')
.setStyle(TextInputStyle.Short);
const firstActionRow = new ActionRowBuilder().addComponents(announcementTitleInput);
announcementModal.addComponents(firstActionRow);
await interaction.showModal(announcementModal);
//await channel.send({content: 'your announcement will look like this:', embeds: [announcementEmbed]});
},
};
And The Error:
DiscordAPIError[10062]: Unknown interaction
at handleErrors (/home/container/node_modules/@discordjs/rest/dist/index.js:727:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async BurstHandler.runRequest (/home/container/node_modules/@discordjs/rest/dist/index.js:831:23)
at async _REST.request (/home/container/node_modules/@discordjs/rest/dist/index.js:1272:22)
at async ChatInputCommandInteraction.showModal (/home/container/node_modules/discord.js/src/structures/interfaces/InteractionResponses.js:257:5)
at async Object.execute (/home/container/src/commands/tools/createannouncement.js:28:9)
at async Object.execute (/home/container/src/events/client/interactionCreate.js:12:9) {
requestBody: { files: undefined, json: { type: 9, data: [Object] } },
rawError: { message: 'Unknown interaction', code: 10062 },
code: 10062,
status: 404,
method: 'POST',
url: 'https://discord.com/api/v10/interactions/1300260874266742834/aW50ZXJhY3Rpb246MTMwMDI2MDg3NDI2Njc0MjgzNDpxeDBNTlhpd1FXam95UzhYUHp5b0tXQnRRUmNxRnVwenFMb1BXNXMwOEw2M1VBcElhMTJpbzdSSWQ4eFNERHd1T211OHA0VHFjaFR1MEkyeWoxY01kdEZmakxtS3hVakN2SEFXWjZ3RTVCQXlDRDU2Q3lCcFZKZktqYmVxVUQxMQ/callback'
}
node:events:491
throw er; // Unhandled 'error' event
^
DiscordAPIError[10062]: Unknown interaction
at handleErrors (/home/container/node_modules/@discordjs/rest/dist/index.js:727:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async BurstHandler.runRequest (/home/container/node_modules/@discordjs/rest/dist/index.js:831:23)
at async _REST.request (/home/container/node_modules/@discordjs/rest/dist/index.js:1272:22)
at async ChatInputCommandInteraction.reply (/home/container/node_modules/discord.js/src/structures/interfaces/InteractionResponses.js:115:5)
at async Object.execute (/home/container/src/events/client/interactionCreate.js:15:9)
Emitted 'error' event on Client instance at:
at emitUnhandledRejectionOrErr (node:events:394:10)
at process.processTicksAndRejections (node:internal/process/task_queues:84:21) {
requestBody: {
files: [],
json: {
type: 4,
data: {
content: 'Something went wrong...',
tts: false,
nonce: undefined,
enforce_nonce: false,
embeds: undefined,
components: undefined,
username: undefined,
avatar_url: undefined,
allowed_mentions: undefined,
flags: 64,
message_reference: undefined,
attachments: undefined,
sticker_ids: undefined,
thread_name: undefined,
applied_tags: undefined,
poll: undefined
}
}
},
rawError: { message: 'Unknown interaction', code: 10062 },
code: 10062,
status: 404,
method: 'POST',
url: 'https://discord.com/api/v10/interactions/1300260874266742834/aW50ZXJhY3Rpb246MTMwMDI2MDg3NDI2Njc0MjgzNDpxeDBNTlhpd1FXam95UzhYUHp5b0tXQnRRUmNxRnVwenFMb1BXNXMwOEw2M1VBcElhMTJpbzdSSWQ4eFNERHd1T211OHA0VHFjaFR1MEkyeWoxY01kdEZmakxtS3hVakN2SEFXWjZ3RTVCQXlDRDU2Q3lCcFZKZktqYmVxVUQxMQ/callback'
}
Node.js v19.9.0