- What's your exact discord.js
npm list discord.jsand nodenode -vversion? - Not a discord.js issue? Check out #1081585952654360687.
- 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!
#Bot not working after 1 day
13 messages · Page 1 of 1 (latest)
Common causes of DiscordAPIError[10062]: Unknown interaction:
- Initial response took more than 3 seconds ➞ defer the response *.
- Wrong interaction object inside a collector.
- Two processes handling the same command (the first consumes the interaction, so it won't be valid for the other instance)
* Note: you cannot defer modal or autocomplete value responses
Line 208 you only reply to the interaction after the DM got sent. That might take too long, you should deferReply first and editReply in the .then and .catch
Or to be safe always deferReply at the top of interactionCreate and then replace all reply with editReply
} else if (commandName === 'varningar') {
const user = interaction.user;
const userId = user.id;
const userWarningsData = userWarnings.get(userId) || [];
interaction.deferReply()
.then(() => {
if (userWarningsData.length > 0) {
user.send(Du har ${userWarningsData.length} varning(ar))
.then(() => interaction.editReply('Skickade dig ett DM med dina varningar.'))
.catch(() => interaction.editReply('Misslyckades med att skicka dig DM med dina varningar. Var god se till att dina DM är öppna.'));
} else {
interaction.editReply('Du har inga varningar.');
}
});
}
oh like this?
What does? And what’s happening in discord itself
} else if (commandName === 'varningar') {
const user = interaction.user;
const userId = user.id;
const userWarningsData = userWarnings.get(userId) || [];
interaction.deferReply({ ephemeral: true });
if (userWarningsData.length > 0) {
user.send(`Du har ${userWarningsData.length} varning(ar)`)
.then(() => {
interaction.editReply('Skickade dig ett DM med dina varningar.')
.catch(console.error);
})
.catch((error) => {
console.error(error);
interaction.editReply('Misslyckades med att skicka dig DM med dina varningar. Var god se till att dina DM är öppna.');
});
} else {
interaction.editReply('Du har inga varningar.')
.catch(console.error);
}
Should this work instead? so the bot is not shut down.
No need for markdown headings. And tell me what does happen when you run that code, not ask me what would happen. You have the code, you can run it
What should happen is that the bot will show you how many warnings you have. It sends a DM with how many alerts you have.