#Can't use commands of other files

13 messages · Page 1 of 1 (latest)

jaunty sand
#

I've made a folder with the commands and i've put there a folder called test for the ping command and the user command. I've done the command handler and it doesn't work. That's how the directory looks.

grand hornetBOT
#
  • What's your exact discord.js npm list discord.js and node node -v version?
  • Not a discord.js issue? Check out #1081585952654360687.
  • 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
jaunty sand
# grand hornet - What's your exact discord.js `npm list discord.js` and node `node -v` version?...

Node Version: 21.4.0
npm list discord.js: [email protected]
The commands don't appear when i write / with the bot + i have the ping command that normally you do in the index.js but i removed it (https://discord.js.org/docs/packages/discord.js/14.15.3) now i have that one /ping command even if i removed it from the code, instead of having the ping command of my ping.js file.

ping.js:

const { SlashCommandBuilder } = require('discord.js')

module.exports = {
    data: new SlashCommandBuilder()
        .setName('ping')
        .setDescription('Testing 2'),
    async execute(interaction) {
        await interaction.reply('Pong!');
    },
};
discord.js

discord.js is a powerful Node.js module that allows you to interact with the Discord API very easily. It takes a much more object-oriented approach than most other JS Discord libraries, making your bot's code significantly tidier and easier to comprehend.

frail bisonBOT
#

To share long code snippets, use a service like gist, sourcebin, pastebin, or similar instead of posting them as large code blocks or files.

jaunty sand
proven tapir
#

Did you deploy those commands with a deployment script after adding/changing them?

jaunty sand
proven tapir
#

No. I meant registering your commands to discord API. Either by rest.put to the applicationCommands route or by doing <Client>.application.commands.set(…)

proven tapir
#

You need to

jaunty sand
proven tapir
#

Yes