Saturday, April 13, 2024
 Popular · Latest · Hot · Upcoming
rated 0 times [  80] [ 7]  / answers: 1 / hits: 9544  / 3 Years ago, fri, october 8, 2021, 12:00:00

I'm making a slash command to send a user info about command when they use /help but when I add more than one command I just get this error:

throw new DiscordAPIError(data, res.status, request);

DiscordAPIError: Unknown interaction
at RequestHandler.execute (E:v13node_modulesdiscord.jssrcrestRequestHandler.js:298:13)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async RequestHandler.push (E:v13node_modulesdiscord.jssrcrestRequestHandler.js:50:14)
at async CommandInteraction.reply (E:v13node_modulesdiscord.jssrcstructuresinterfacesInteractionResponses.js:98:5) {
method: 'post',
path: '/interactions/[EDITED]/callback',
code: 10062,
httpStatus: 404,
requestData: {
json: {
type: 4,
data: {
content: undefined,
tts: false,
nonce: undefined,
embeds: [
title: 'Help Menu ➞ test',
type: 'rich',
description: null,
url: null,
timestamp: 0,
color: 3447003,
fields: [Array],
thumbnail: null,
image: null,
author: null,
footer: [Object]
components: undefined,
username: undefined,
avatar_url: undefined,
allowed_mentions: undefined,
flags: undefined,
message_reference: undefined,
attachments: undefined,
sticker_ids: undefined
files: []

My code:

            interaction.client.commands.each((cmd) => {
if( == args[0].toLowerCase() || cmd.aliases.includes(args[0].toLowerCase())) {
embed.setTitle("Help Menu" + " " + "➞" + " " + `${}`)
embed.addField("**Description**", `${cmd.description}`, false)
embed.addField("**Usage**", `${cmd.usage}`, true)
embed.addField("**Aliases**", `${cmd.alias}`, true)
embed.addField("**Examples**", `${cmd.examples}`, true)
interaction.reply({ embeds: [embed], ephemeral: false });
} else {
interaction.reply({ content: `Command you requested help for does not exist!`, ephemeral: true });

It is working just fine when I have only one command in commands folder, but if I add second command I can use this command once and if I use it again - my bot crashes! Also it can't find 2nd command and only can see first one

Update 1: I changed my code a bit and now it can find 2nd command but if I try to search for command by its alias, it sends me command info and crash the bot with the same error!
Basically I just added:

            if(!found) {
interaction.reply({ content: `Command you requested help for does not exist!`, ephemeral: true });
} else {
interaction.reply({ embeds: [embed], ephemeral: false });

More From » node.js


Your app needs to respond to the discord interaction within 3 seconds, otherwise the interaction is ended from Discord's end and you will get this error.

For slash commands, you can defer your response by executing the following:

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

This will then wait for you to run through whatever logic you need and follow up with:

interaction.reply({ embeds: [embed] })

Note that you can only set the ephemeral flag on the initial response, so you need to know if it's going to be epherimal or not at the time you defer.

Also note, if you implement autocomplete for a slashcommand, you can't defer. You need to send your full response within the 3 seconds timeframe.

I would recommend reading the discordjs guide site, particularly this page.

[#787] Wednesday, September 29, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.

Total Points: 117
Total Questions: 116
Total Answers: 116

Location: Bangladesh
Member since Sat, Jan 23, 2021
3 Years ago
maxinec questions