Collectro recieved no interaction before ending with reason: time

I have a signup modal that has a collector on it. But I don't know how to prevent it from crashing if the time expires. const submit = await interaction.awaitModalSubmit({ filter: (interaction) => interaction.isModalSubmit() && interaction.customId === 'signup_modal', time: 60000 });
const minecraftUsername = await submit.fields.getTextInputValue('minecraftusername');
const event = db.get(events.${eventId}); if (!event) { return await submit.reply("Event not found. Please try again."); } event.participants = event.participants || []; event.participants.push({ userId, minecraftUsername }); db.set(events.${eventId}, event);
await submit.reply("You have successfully signed up for the event.");
23 Replies
d.js toolkit
d.js toolkit9mo 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! - Marked as resolved by OP
d.js docs
d.js docs9mo ago
:mdn: try...catch The try...catch statement is comprised of a try block and either a catch block, a finally block, or both. The code in the try block is executed first, and if it throws an exception, the code in the catch block will be executed. The code in the finally block will always be executed before control flow exits the entire construct. :mdn: Promise.prototype.catch() The catch() method of Promise instances schedules a function to be called when the promise is rejected. It immediately returns an equivalent Promise object, allowing you to chain calls to other promise methods. It is a shortcut for Promise.prototype.then(undefined, onRejected).
Acemavie
AcemavieOP9mo ago
It fixed it!
Acemavie
AcemavieOP9mo ago
But I have a another problem too. I have a embed that is created using a command and has 3 buttons. But after restarting the bot they will no longer work. And also they wont work after some period of time. Beacuse the collector Is there a way to fix both of these issues? Here is my full code: https://pastebin.com/nNgGbUEj
Pastebin
const { SlashCommandBuilder } = require('discord.js');const createE...
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.
NyR
NyR9mo ago
If you want the buttons to work all the times, handle it directly in the interactionCreate event instead of using a Collector
Acemavie
AcemavieOP9mo ago
I made some modifications but still it seems to not work after restarting the bot https://pastebin.com/BiSwFc1s
Pastebin
const { SlashCommandBuilder, EmbedBuilder, ActionRowBuilder, Button...
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.
NyR
NyR9mo ago
Uh, no! Do not create a listener inside a command, that is a bad idea. you should already have an interaction handler, do it there. How do you handle slash commands ( or listen to slash command interactions?)
Acemavie
AcemavieOP9mo ago
I could be mistaken but I think this is it. I used a template to start off module.exports = { name: 'interactionCreate', async execute(interaction, client) { if (interaction.isChatInputCommand()) { const { commands } = client const { commandName } = interaction const command = commands.get(commandName) if(!command) return try { await command.execute(interaction, client) } catch (error) { console.error(error) await interaction.reply({ content: Something Went Wrong on our side! Please contact us via tickets!, ephemeral: true }) } } } }
NyR
NyR9mo ago
Yes, that is it. Handle the buttons there
Acemavie
AcemavieOP9mo ago
I have one problem the if statement uses the message.id. But that's not present there https://pastebin.com/u3ZNThMT
Pastebin
const handleSignup = require('../../utils/signup');const removeEntr...
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.
No description
NyR
NyR9mo ago
You can look for button's customId, make sure it's unique so you can differentiate it with others Also this is wrong
Acemavie
AcemavieOP9mo ago
I just realized that too when I tried to click on the button interaction.on is not a function
NyR
NyR9mo ago
There is no interaction.on(), you already listen to interaction there, no need to try to create another listener, make another if block with if (interaction.isButton()) like you do for ChatInputCommand Because it isn't, ^
Acemavie
AcemavieOP9mo ago
node:events:492
throw er; // Unhandled 'error' event
^

DiscordAPIError[50035]: Invalid Form Body
data.components[0].components[BASE_TYPE_BAD_LENGTH]: Must be between 1 and 5 in length.
at handleErrors (R:\1) Developer\Discord bots\Foxia\Foxia Events\node_modules\@discordjs\rest\dist\index.js:722:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async BurstHandler.runRequest (R:\1) Developer\Discord bots\Foxia\Foxia Events\node_modules\@discordjs\rest\dist\index.js:826:23)
at async _REST.request (R:\1) Developer\Discord bots\Foxia\Foxia Events\node_modules\@discordjs\rest\dist\index.js:1266:22)
at async ButtonInteraction.showModal (R:\1) Developer\Discord bots\Foxia\Foxia Events\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:253:5)
at async handleSignup (R:\1) Developer\Discord bots\Foxia\Foxia Events\src\utils\signup.js:34:5)
at async Object.execute (R:\1) Developer\Discord bots\Foxia\Foxia Events\src\events\client\interactionCreate.js:31:25)
Emitted 'error' event on Client instance at:
at emitUnhandledRejectionOrErr (node:events:395:10)
at process.processTicksAndRejections (node:internal/process/task_queues:84:21) {
requestBody: {
files: undefined,
json: {
type: 9,
data: {
custom_id: 'signup_modal',
title: 'Sign Up',
components: [ { type: 1, data: [Object], components: [] } ]
}
}
},
rawError: {
message: 'Invalid Form Body',
code: 50035,
errors: {
data: { components: { '0': { components: [Object] } } }
}
},
code: 50035,
status: 400,
method: 'POST',
url: 'https://discord.com/api/v10/interactions/1216337739591716885/aW50ZXJhY3Rpb246MTIxNjMzNzczOTU5MTcxNjg4NTpBYVRPdG9KbmZSM0lSc0NKQjdvS1RrZWI0MEFWY2dqSUl4ZHJrVWp6cGxsMzhVcmFuQ0hsYWJ2ZXUwM3lTR0VrNXAzdHNsQnlOOUJNVDZTZWRiVGtoZHZITEdEVkQ2eEl5b1BoQjNTbVBib1RMT0llZUs5MktQUWZmZ3hWQ1lEcQ/callback'
}

Node.js v18.17.1
node:events:492
throw er; // Unhandled 'error' event
^

DiscordAPIError[50035]: Invalid Form Body
data.components[0].components[BASE_TYPE_BAD_LENGTH]: Must be between 1 and 5 in length.
at handleErrors (R:\1) Developer\Discord bots\Foxia\Foxia Events\node_modules\@discordjs\rest\dist\index.js:722:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async BurstHandler.runRequest (R:\1) Developer\Discord bots\Foxia\Foxia Events\node_modules\@discordjs\rest\dist\index.js:826:23)
at async _REST.request (R:\1) Developer\Discord bots\Foxia\Foxia Events\node_modules\@discordjs\rest\dist\index.js:1266:22)
at async ButtonInteraction.showModal (R:\1) Developer\Discord bots\Foxia\Foxia Events\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:253:5)
at async handleSignup (R:\1) Developer\Discord bots\Foxia\Foxia Events\src\utils\signup.js:34:5)
at async Object.execute (R:\1) Developer\Discord bots\Foxia\Foxia Events\src\events\client\interactionCreate.js:31:25)
Emitted 'error' event on Client instance at:
at emitUnhandledRejectionOrErr (node:events:395:10)
at process.processTicksAndRejections (node:internal/process/task_queues:84:21) {
requestBody: {
files: undefined,
json: {
type: 9,
data: {
custom_id: 'signup_modal',
title: 'Sign Up',
components: [ { type: 1, data: [Object], components: [] } ]
}
}
},
rawError: {
message: 'Invalid Form Body',
code: 50035,
errors: {
data: { components: { '0': { components: [Object] } } }
}
},
code: 50035,
status: 400,
method: 'POST',
url: 'https://discord.com/api/v10/interactions/1216337739591716885/aW50ZXJhY3Rpb246MTIxNjMzNzczOTU5MTcxNjg4NTpBYVRPdG9KbmZSM0lSc0NKQjdvS1RrZWI0MEFWY2dqSUl4ZHJrVWp6cGxsMzhVcmFuQ0hsYWJ2ZXUwM3lTR0VrNXAzdHNsQnlOOUJNVDZTZWRiVGtoZHZITEdEVkQ2eEl5b1BoQjNTbVBib1RMT0llZUs5MktQUWZmZ3hWQ1lEcQ/callback'
}

Node.js v18.17.1
I got that error when clicking the button now
NyR
NyR9mo ago
Show you signup.js file, but in general modals should have at least 1 text input and not more than 5
Acemavie
AcemavieOP9mo ago
Pastebin
const { QuickDB } = require('quick.db');const { ModalBuilder, TextI...
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.
NyR
NyR9mo ago
Text Input should be added as a component in ActionRowBuilder first
Acemavie
AcemavieOP9mo ago
ActionRowBuilder?
d.js docs
d.js docs9mo ago
:guide: Other Interactions: Modals - Building and responding with modals read more
NyR
NyR9mo ago
Please read this guide, it shows how to work with modals
Acemavie
AcemavieOP9mo ago
I did when I was creating the modal. I t worked originally until I tried fixing the button issue But I'll read it again
NyR
NyR9mo ago
Shouldn't have worked, because you are only building the text input and not the row It should be something like
modal.addComponents(new ActionRowBuilder().addComponents(minecraftUsernameInput))
modal.addComponents(new ActionRowBuilder().addComponents(minecraftUsernameInput))
Acemavie
AcemavieOP9mo ago
Oh Thanks alot, I got my issue fixed!
Want results from more Discord servers?
Add your server