Dopi
Dopi
DIdiscord.js - Imagine ❄
Created by Dopi on 12/16/2024 in #djs-questions
SlashCommand interaction is undefined
Hey, I just encountered an Error I can't explain... I get an error every time I execute an SlashCommand from my Bot telling me "interaction" is undefined. I haven't changed anything in my App for a couple of weeks, so I can't tell when this error started to occur. Things I've checked: - if discord.js has a newer version that i can install - already had the latest version 14.16.3 - I republished my SlashCommands to Discord - still not working This is an example breakdown of a command in my Application:
module.exports = {
data: new SlashCommandBuilder()
.setName('joke')
.setDescription('Tells a Joke!'),
async execute(interaction: CommandInteraction) {
await interaction.deferReply({ ephemeral: false }) // this line already throws the error
// here is just some code to response
}
};
module.exports = {
data: new SlashCommandBuilder()
.setName('joke')
.setDescription('Tells a Joke!'),
async execute(interaction: CommandInteraction) {
await interaction.deferReply({ ephemeral: false }) // this line already throws the error
// here is just some code to response
}
};
Here is the Stacktrace (I edited the path to make it more readable)
TypeError: Cannot read properties of undefined (reading 'deferReply')
at Object.execute (/path/to/bot/dist/discord/commands/community/joke.js:13:27)
at Object.execute (/path/to/bot/dist/discord/events/interactionCreate.js:15:27)
at Client.<anonymous> (/path/to/bot/dist/discord/DiscordClient.js:105:56)
at Client.emit (node:events:513:28)
at InteractionCreateAction.handle (/path/to/bot/node_modules/discord.js/src/client/actions/InteractionCreate.js:97:12)
at module.exports [as INTERACTION_CREATE] (/path/to/bot/node_modules/discord.js/src/client/websocket/handlers/INTERACTION_CREATE.js:4:36)
at WebSocketManager.handlePacket (/path/to/bot/node_modules/discord.js/src/client/websocket/WebSocketManager.js:348:31)
at WebSocketManager.<anonymous> (/path/to/bot/node_modules/discord.js/src/client/websocket/WebSocketManager.js:232:12)
at WebSocketManager.emit (/path/to/bot/node_modules/@vladfrangu/async_event_emitter/dist/index.cjs:287:31)
at WebSocketShard.<anonymous> (/path/to/bot/node_modules/@discordjs/ws/dist/index.js:1190:51)
TypeError: Cannot read properties of undefined (reading 'deferReply')
at Object.execute (/path/to/bot/dist/discord/commands/community/joke.js:13:27)
at Object.execute (/path/to/bot/dist/discord/events/interactionCreate.js:15:27)
at Client.<anonymous> (/path/to/bot/dist/discord/DiscordClient.js:105:56)
at Client.emit (node:events:513:28)
at InteractionCreateAction.handle (/path/to/bot/node_modules/discord.js/src/client/actions/InteractionCreate.js:97:12)
at module.exports [as INTERACTION_CREATE] (/path/to/bot/node_modules/discord.js/src/client/websocket/handlers/INTERACTION_CREATE.js:4:36)
at WebSocketManager.handlePacket (/path/to/bot/node_modules/discord.js/src/client/websocket/WebSocketManager.js:348:31)
at WebSocketManager.<anonymous> (/path/to/bot/node_modules/discord.js/src/client/websocket/WebSocketManager.js:232:12)
at WebSocketManager.emit (/path/to/bot/node_modules/@vladfrangu/async_event_emitter/dist/index.cjs:287:31)
at WebSocketShard.<anonymous> (/path/to/bot/node_modules/@discordjs/ws/dist/index.js:1190:51)
npm list: [email protected] node -v: v20.16.0 If you need more information just let me know ...
15 replies