DiscordAPIError[10062]: Unknown interaction

async function handleReaction(client, interaction, challenger, opponent, embed, logs) {
try {
const collectorFilter = (reaction, user) => ['👍', '👎'].includes(reaction.emoji.name) && user.id === opponent.user.id;
const reactionCollector = await embed.awaitReactions({ filter: collectorFilter, max: 1, time: 5000, errors: ['time'] });
const reaction = reactionCollector.first();

if (reaction.emoji.name === '👍') {
embed.setFooter({ text: `Challenge #${client.challengeID}` });
embed.setTimestamp();
await challengeEmbed.edit({ embeds: [embed] });
} else if (reaction.emoji.name === '👎') {
await embed.delete({ timeout: 1000 });
await logs.channel.send(`<@${challenger.id}> ${opponent.user.username} rejected your challenge`);
}
} catch (error) {
console.log(interaction);
await interaction.reply("no time left");
throw new Error(error);
}
}

async execute(client, interaction) {
const challenger = interaction.member.user
const opponent = interaction.options.get("opponent")
try {
const match = await createMatchRequest(interaction, challenger, opponent)
await handleReaction(client, interaction, challenger, opponent, match.embed, match.logs)
} catch (error) {
console.log(error)
}
}
async function handleReaction(client, interaction, challenger, opponent, embed, logs) {
try {
const collectorFilter = (reaction, user) => ['👍', '👎'].includes(reaction.emoji.name) && user.id === opponent.user.id;
const reactionCollector = await embed.awaitReactions({ filter: collectorFilter, max: 1, time: 5000, errors: ['time'] });
const reaction = reactionCollector.first();

if (reaction.emoji.name === '👍') {
embed.setFooter({ text: `Challenge #${client.challengeID}` });
embed.setTimestamp();
await challengeEmbed.edit({ embeds: [embed] });
} else if (reaction.emoji.name === '👎') {
await embed.delete({ timeout: 1000 });
await logs.channel.send(`<@${challenger.id}> ${opponent.user.username} rejected your challenge`);
}
} catch (error) {
console.log(interaction);
await interaction.reply("no time left");
throw new Error(error);
}
}

async execute(client, interaction) {
const challenger = interaction.member.user
const opponent = interaction.options.get("opponent")
try {
const match = await createMatchRequest(interaction, challenger, opponent)
await handleReaction(client, interaction, challenger, opponent, match.embed, match.logs)
} catch (error) {
console.log(error)
}
}
- When I wait longer than the reaction time for awaitReactions to reach the catch block of handleReaction - The interaction object is not deferred and replied is false - When trying to reply to the interaction inside of the catch block, I get the discord api error: DiscordAPIError[10062]: Unknown interaction Can someone explain why this error is thrown?
2 Replies
d.js toolkit
d.js toolkit14mo 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 docs14mo 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
Want results from more Discord servers?
Add your server