Reload Commands

Hello, I'd like to update my bot's commands with a command on Discord. I've followed the instructions on this page (https://discordjs.guide/additional-features/reloading-commands.html) but when I run the /reload ping command I get this error.
Error: Cannot find module '../undefined/ping.js'
Require stack:
- C:\Users\quen0\Downloads\discord-bot2\commands\administration\reload.js
- C:\Users\quen0\Downloads\discord-bot2\index.js
at Module._resolveFilename (node:internal/modules/cjs/loader:1077:15)
at Function.resolve (node:internal/modules/cjs/helpers:116:19)
at Object.execute (C:\Users\quen0\Downloads\discord-bot2\commands\administration\reload.js:19:32)
at Client.<anonymous> (C:\Users\quen0\Downloads\discord-bot2\index.js:45:17)
at Client.emit (node:events:514:28)
at InteractionCreateAction.handle (C:\Users\quen0\Downloads\discord-bot2\node_modules\discord.js\src\client\actions\InteractionCreate.js:97:12)
at module.exports [as INTERACTION_CREATE] (C:\Users\quen0\Downloads\discord-bot2\node_modules\discord.js\src\client\websocket\handlers\INTERACTION_CREATE.js:4:36) )
at WebSocketManager.handlePacket (C:\Users\quen0\Downloads\discord-bot2\node_modules\discord.js\src\client\websocket\WebSocketManager.js:355:31)
at WebSocketManager.<anonymous> (C:\Users\quen0\Downloads\discord-bot2\node_modules\discord.js\src\client\websocket\WebSocketManager.js:239:12)
at WebSocketManager.emit (C:\Users\quen0\Downloads\discord-bot2\node_modules\@vladfrangu\async_event_emitter\dist\index.js:282:31) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'C:\\Users\\quen0\\Downloads\\discord-bot2\\commands\\administration\\reload.js',
'C:\\Users\\quen0\\Downloads\\discord-bot2\\index.js'
]
}
Error: Cannot find module '../undefined/ping.js'
Require stack:
- C:\Users\quen0\Downloads\discord-bot2\commands\administration\reload.js
- C:\Users\quen0\Downloads\discord-bot2\index.js
at Module._resolveFilename (node:internal/modules/cjs/loader:1077:15)
at Function.resolve (node:internal/modules/cjs/helpers:116:19)
at Object.execute (C:\Users\quen0\Downloads\discord-bot2\commands\administration\reload.js:19:32)
at Client.<anonymous> (C:\Users\quen0\Downloads\discord-bot2\index.js:45:17)
at Client.emit (node:events:514:28)
at InteractionCreateAction.handle (C:\Users\quen0\Downloads\discord-bot2\node_modules\discord.js\src\client\actions\InteractionCreate.js:97:12)
at module.exports [as INTERACTION_CREATE] (C:\Users\quen0\Downloads\discord-bot2\node_modules\discord.js\src\client\websocket\handlers\INTERACTION_CREATE.js:4:36) )
at WebSocketManager.handlePacket (C:\Users\quen0\Downloads\discord-bot2\node_modules\discord.js\src\client\websocket\WebSocketManager.js:355:31)
at WebSocketManager.<anonymous> (C:\Users\quen0\Downloads\discord-bot2\node_modules\discord.js\src\client\websocket\WebSocketManager.js:239:12)
at WebSocketManager.emit (C:\Users\quen0\Downloads\discord-bot2\node_modules\@vladfrangu\async_event_emitter\dist\index.js:282:31) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'C:\\Users\\quen0\\Downloads\\discord-bot2\\commands\\administration\\reload.js',
'C:\\Users\\quen0\\Downloads\\discord-bot2\\index.js'
]
}
What should I do? Attached is a photo of how my commands are arranged and the code from the Github example of the DJS guide.
discord.js Guide
Imagine a guide... that explores the many possibilities for your discord.js bot.
14 Replies
d.js toolkit
d.js toolkitâ€ĸ16mo 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!
treble/luna
treble/lunaâ€ĸ16mo ago
Your error isnt really djs related one of your commands properties is undefined
𝑆𝑘đ‘ĸ𝑙𝑙đ‘Ļ āļž
So is it a problem in the command I performed or in the code?
treble/luna
treble/lunaâ€ĸ16mo ago
one of both Your top line shows whats wrong Your path is wrong
𝑆𝑘đ‘ĸ𝑙𝑙đ‘Ļ āļž
I've seen this but I don't know how to define the path correctly. I tried with the following commands but when I run it it tells me that no command was found - /reload ./commands/informations/ping.js - /reload commands/informations/ping.js - /reload ./informations/ping.js - /reload informations/ping.js
treble/luna
treble/lunaâ€ĸ16mo ago
well yeah <String>.category doesnt exist
𝑆𝑘đ‘ĸ𝑙𝑙đ‘Ļ āļž
And there's no indication in the guide of the command to be performed for the path to be correct.
treble/luna
treble/lunaâ€ĸ16mo ago
so that'll always be undefined wait log your command and maek sure each of your commands has a category property
𝑆𝑘đ‘ĸ𝑙𝑙đ‘Ļ āļž
The category property does not correspond to the administration and informations folders located in the commands folder? Because in the original guide there is no category property. It is only present in the Github version This one https://github.com/discordjs/guide/blob/main/code-samples/additional-features/reloading-commands/commands/utility/reload.js
treble/luna
treble/lunaâ€ĸ16mo ago
you do have to set a category your commands wont magically have that property
𝑆𝑘đ‘ĸ𝑙𝑙đ‘Ļ āļž
Do you have a guide or can you tell me how to set the category property on this order, for example please?
treble/luna
treble/lunaâ€ĸ16mo ago
just add a category property rather basic js
𝑆𝑘đ‘ĸ𝑙𝑙đ‘Ļ āļž
Like this? Sorry if I can't do some simple things, I'm just starting out.
const { SlashCommandBuilder } = require('discord.js');

module.exports = {
data: new SlashCommandBuilder()
.setName('ping')
.setDescription('Replies with Pong!')
.setCategories([
{
name: 'Something',
},
]),
async execute(interaction) {
await interaction.reply('Pong!');
},
};
const { SlashCommandBuilder } = require('discord.js');

module.exports = {
data: new SlashCommandBuilder()
.setName('ping')
.setDescription('Replies with Pong!')
.setCategories([
{
name: 'Something',
},
]),
async execute(interaction) {
await interaction.reply('Pong!');
},
};
treble/luna
treble/lunaâ€ĸ16mo ago
no i recommend checking out #resources as djs requires a string js understanding
Want results from more Discord servers?
Add your server