#Bot not working after 1 day

13 messages · Page 1 of 1 (latest)

worn timberBOT
#
  • What's your exact discord.js npm list discord.js and node node -v version?
  • 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!
rough aspen
#

Check the pm2 logs

#

And does it show as online in discord?

barren knoll
primal vortexBOT
#

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
rough aspen
#

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

barren knoll
# rough aspen Line 208 you only reply to the interaction after the DM got sent. That might tak...

} 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?

rough aspen
#

What does? And what’s happening in discord itself

barren knoll
#

} 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.

rough aspen
#

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

barren knoll