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(
await submit.reply("You have successfully signed up for the event.");
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
- 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: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).
It fixed it!
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.
If you want the buttons to work all the times, handle it directly in the interactionCreate event instead of using a Collector
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.
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?)
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 })
}
}
}
}Yes, that is it. Handle the buttons there
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.
You can look for button's customId, make sure it's unique so you can differentiate it with others
Also this is wrong
I just realized that too when I tried to click on the button
interaction.on is not a function
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, ^
I got that error when clicking the button now
Show you signup.js file, but in general modals should have at least 1 text input and not more than 5
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.
Text Input should be added as a component in ActionRowBuilder first
ActionRowBuilder?
Please read this guide, it shows how to work with modals
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
Shouldn't have worked, because you are only building the text input and not the row
It should be something like
Oh
Thanks alot, I got my issue fixed!