I get an error about the interaction
Im trying to make my first discord bot. Currently ive got this
// commands/ping.js
module.exports = {
data: {
name: 'ping',
description: 'Ping command.',
},
async execute(interaction) {
interaction.deferReply();
console.log(interaction.commandName)
console.log(interaction.deferred)
setTimeout(() => {
interaction.followUp('Pong!');
}, 4000);
},
};
My commands/ping.js
require('dotenv').config();
const {Client, IntentsBitField} = require('discord.js');
const Discord = require('discord.js');
const fs = require('fs');
const {configDotenv} = require("dotenv");
const client = new Client({
intents: [
IntentsBitField.Flags.Guilds,
IntentsBitField.Flags.GuildMessages,
IntentsBitField.Flags.GuildMessageReactions,
IntentsBitField.Flags.MessageContent,
],
});
// Load interaction commands dynamically from the "interactions" directory
const interactionFiles = fs.readdirSync('./src/commands').filter(file => file.endsWith('.js'));
const interactions = new Map();
for (const file of interactionFiles) {
const interaction = require(
./commands/${file});
interactions.set(interaction.data.name, interaction);
}
client.once('ready', () => {
console.log(
Logged in as ${client.user.tag}!);
console.log(process.env.CLIENT_ID)
});
client.on('interactionCreate', async interaction => {
if (!interaction.isCommand()) return;
const { commandName } = interaction;
const command = interactions.get(commandName);
if (!command) return;
try {
await command.execute(interaction);
} catch (error) {
console.error(error);
await interaction.reply({ content: 'An error occurred while executing the command.', ephemeral: true });
}
});
client.login(process.env.TOKEN);
And my index.JS
When i run this from my pc it works perfectly but once ive dockerized it and put it on portainer to run from my server i get an error.7 Replies
- 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!The response
ping
false
/app/node_modules/@discordjs/rest/dist/index.js:687
throw new DiscordAPIError(data, "code" in data ? data.code : data.error, status, method, url, requestData);
^
DiscordAPIError[10062]: Unknown interaction
at handleErrors (/app/node_modules/@discordjs/rest/dist/index.js:687:13)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async BurstHandler.runRequest (/app/node_modules/@discordjs/rest/dist/index.js:786:23)
at async _REST.request (/app/node_modules/@discordjs/rest/dist/index.js:1218:22)
at async ChatInputCommandInteraction.reply (/app/node_modules/discord.js/src/structures/interfaces/InteractionResponses.js:111:5) {
requestBody: {
files: [],
json: {
type: 4,
data: {
content: 'Pong!',
tts: false,
}
}
},
rawError: { message: 'Unknown interaction', code: 10062 },
code: 10062,
status: 404,
method: 'POST',
url Logged in as TestingBot#5037!
ping
false
/app/node_modules/@discordjs/rest/dist/index.js:687
throw new DiscordAPIError(data, "code" in data ? data.code : data.error, status, method, url, requestData);
DiscordAPIError[10062]: Unknown interaction
at handleErrors (/app/node_modules/@discordjs/rest/dist/index.js:687:13)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async BurstHandler.runRequest (/app/node_modules/@discordjs/rest/dist/index.js:786:23)
at async _REST.request (/app/node_modules/@discordjs/rest/dist/index.js:1218:22)
at async ChatInputCommandInteraction.reply (/app/node_modules/discord.js/src/structures/interfaces/InteractionResponses.js:111:5) {
requestBody: {
files: [],
json: {
type: 4,
data: {
content: 'Pong!',
tts: false,
}
}
},
rawError: { message: 'Unknown interaction', code: 10062 },
code: 10062,
status: 404,
method: 'POST',
url: 'https://discord.com/api/v10/interactions/.....'
}
Node version 16.20.2
DiscordJS 14.12.1Common 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 responsesbut why does it work on my pc but not on my server?
if you use deferReply you need to do editReply instead of plain reply
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/app/node_modules/@discordjs/rest/dist/index.js:687
throw new DiscordAPIError(data, "code" in data ? data.code : data.error, status, method, url, requestData);
^
DiscordAPIError[10062]: Unknown interaction
at handleErrors (/app/node_modules/@discordjs/rest/dist/index.js:687:13)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async BurstHandler.runRequest (/app/node_modules/@discordjs/rest/dist/index.js:786:23)
at async _REST.request (/app/node_modules/@discordjs/rest/dist/index.js:1218:22)
at async ChatInputCommandInteraction.deferReply (/app/node_modules/discord.js/src/structures/interfaces/InteractionResponses.js:69:5) {
requestBody: { files: undefined, json: { type: 5, data: { flags: undefined } } },
rawError: { message: 'Unknown interaction', code: 10062 },
code: 10062,
status: 404,
method: 'POST',
url: 'https://discord.com/api/v10/interactions/
Now this is my error... still the same interaction error
No im just running the docker variant in portainer
The application did not respond Thats what discord is saying