problem with modal

hello i have problem. when two people fill out the modal at the same time, it bugs out and throws an error in the console. ```async execute(interaction) { if(interaction.customId === 'aplikujmod'){ const modal = new ModalBuilder() .setCustomId('rekrumod'+interaction.user.id) .setTitle('Formularz na Moderatora'); const imie = new TextInputBuilder() .setCustomId('imie-'+interaction.user.id+'') .setPlaceholder('Imię i nazwisko') .setLabel("Imię i nazwisko") .setRequired(true) .setStyle(TextInputStyle.Short); const doswiadczenie = new TextInputBuilder() .setCustomId('doswiadczenie-'+interaction.user.id) .setPlaceholder('Tak/Nie, jak tak to jakie?') .setLabel("Czy masz doświadczenie w moderowaniu?") .setRequired(true) .setStyle(TextInputStyle.Short); const imieRow = new ActionRowBuilder().addComponents(imie); const doswiadczenieRow = new ActionRowBuilder().addComponents(doswiadczenie); modal.addComponents(imieRow, doswiadczenieRow); const filter = (interaction) => interaction.customId === 'rekrumod'+interaction.user.id; interaction.showModal(modal); interaction .awaitModalSubmit({ filter, time: 1000_000}) .then(async (modalInteraction) => { const imieText = modalInteraction.fields.getTextInputValue('imie-'+interaction.user.id+''); const doswiadczenieText = modalInteraction.fields.getTextInputValue('doswiadczenie-'+interaction.user.id); const embed = new EmbedBuilder() .setTitle("Rekrutacja na Moderatora") .setDescription('Aplikacja użytkownika: <@' + interaction.user.id + '>') .addFields(fields but i delete it because too many characters ) .setThumbnail("https://imgur.com/FCbVUO5.png") .setFooter({ text: "E-Sport Szczytno", iconURL: "https://imgur.com/
12 Replies
d.js toolkit
d.js toolkit8mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button!
Unknown User
Unknown User8mo ago
Message Not Public
Sign In & Join Server To View
ajzak
ajzakOP8mo ago
i do
const modal = new ModalBuilder()
.setCustomId('rekrumod'+interaction.user.id)
const modal = new ModalBuilder()
.setCustomId('rekrumod'+interaction.user.id)
and i have new problem
J:\Projekty Node.js\e-sport szczytno\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:102
if (this.deferred || this.replied) throw new DiscordjsError(ErrorCodes.InteractionAlreadyReplied);
^

Error [InteractionAlreadyReplied]: The reply to this interaction has already been sent or deferred.
at ModalSubmitInteraction.reply (J:\Projekty Node.js\e-sport szczytno\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:102:46)
at J:\Projekty Node.js\e-sport szczytno\events\RekrutacjaModEvent.js:86:44
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
code: 'InteractionAlreadyReplied'
}
J:\Projekty Node.js\e-sport szczytno\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:102
if (this.deferred || this.replied) throw new DiscordjsError(ErrorCodes.InteractionAlreadyReplied);
^

Error [InteractionAlreadyReplied]: The reply to this interaction has already been sent or deferred.
at ModalSubmitInteraction.reply (J:\Projekty Node.js\e-sport szczytno\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:102:46)
at J:\Projekty Node.js\e-sport szczytno\events\RekrutacjaModEvent.js:86:44
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
code: 'InteractionAlreadyReplied'
}
xd
Unknown User
Unknown User8mo ago
Message Not Public
Sign In & Join Server To View
ajzak
ajzakOP8mo ago
i hope im reading the right message. idk how to create a unique id for a button when the button is always on the same channel
Unknown User
Unknown User8mo ago
Message Not Public
Sign In & Join Server To View
ajzak
ajzakOP8mo ago
wait, i have mindfuck xd
const modal = new ModalBuilder()
.setCustomId(interaction.user.id)
const modal = new ModalBuilder()
.setCustomId(interaction.user.id)
and what? i wrote it in the wrong place?
Unknown User
Unknown User8mo ago
Message Not Public
Sign In & Join Server To View
ajzak
ajzakOP8mo ago
"interaction.user.id" this? how else can i retrieve the user id?
Unknown User
Unknown User8mo ago
Message Not Public
Sign In & Join Server To View
ajzak
ajzakOP8mo ago
async execute(interaction) {
console.log('first '+interaction.id)
if(interaction.customId === 'aplikujmod'){
console.log('second '+interaction.id)
const modal = new ModalBuilder()
.setCustomId('rekrumod'+interaction.id)
.setTitle('Formularz na Moderatora');
[........]
const doswiadczenieRow = new ActionRowBuilder().addComponents(doswiadczenie);
modal.addComponents(imieRow, wiekRow, dlaczegoRow, doswiadczenieRow);
const filter = (interaction) => interaction.customId === 'rekrumod'+interaction.id;
console.log('third '+interaction.id)
async execute(interaction) {
console.log('first '+interaction.id)
if(interaction.customId === 'aplikujmod'){
console.log('second '+interaction.id)
const modal = new ModalBuilder()
.setCustomId('rekrumod'+interaction.id)
.setTitle('Formularz na Moderatora');
[........]
const doswiadczenieRow = new ActionRowBuilder().addComponents(doswiadczenie);
modal.addComponents(imieRow, wiekRow, dlaczegoRow, doswiadczenieRow);
const filter = (interaction) => interaction.customId === 'rekrumod'+interaction.id;
console.log('third '+interaction.id)
in console
first 1227039301020160040
second 1227039301020160040
third 1227039301020160040
first 1227039301020160040
second 1227039301020160040
third 1227039301020160040
and when i complete modal
first 1227039331802284033
first 1227039331802284033
the id is different and im not getting the code to respond to the modal
Unknown User
Unknown User8mo ago
Message Not Public
Sign In & Join Server To View
Want results from more Discord servers?
Add your server