Unknown Interaction

I have came to a problem where when I randomly run commands, my bot crashes with the error "Unknown Interaction"..
client.on(Events.InteractionCreate, async interaction => {
if (!interaction.isChatInputCommand()) return;

await interaction.deferReply({ ephemeral: true });

const command = client.commands.get(interaction.commandName);
if (!command) { return await interaction.editReply({ content: 'The command file does not exist!', ephemeral: true }) };

const botMember = interaction.guild.members.cache.get(client.user.id);
if (!botMember.permissions.has(PermissionsBitField.Flags.Administrator)) { return await interaction.editReply({ content: 'Bot is missing the `ADMINISTRATOR` permission!', ephemeral: true }) };

await command.execute(interaction, client, interaction.user.username, ref(getDatabase()));
});
client.on(Events.InteractionCreate, async interaction => {
if (!interaction.isChatInputCommand()) return;

await interaction.deferReply({ ephemeral: true });

const command = client.commands.get(interaction.commandName);
if (!command) { return await interaction.editReply({ content: 'The command file does not exist!', ephemeral: true }) };

const botMember = interaction.guild.members.cache.get(client.user.id);
if (!botMember.permissions.has(PermissionsBitField.Flags.Administrator)) { return await interaction.editReply({ content: 'Bot is missing the `ADMINISTRATOR` permission!', ephemeral: true }) };

await command.execute(interaction, client, interaction.user.username, ref(getDatabase()));
});
No description
9 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!
d.js docs
d.js docs9mo ago
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
treble/luna
treble/luna9mo ago
if its already unknown before it reaches the defer, check the 3rd bullet point and your network/host
gandhi20
gandhi209mo ago
Mmm, I will try resetting the token
treble/luna
treble/luna9mo ago
it could also be multiple listeners
gandhi20
gandhi209mo ago
Mmm, thinking about two processes, I did change like 5 hosting providers in the last year, I might have forgot to turn one off. Ima just reset the token
gandhi20
gandhi209mo ago
nope issue is still happening
No description
treble/luna
treble/luna9mo ago
then its probably a host / network issue
gandhi20
gandhi209mo ago
mm