OS Windows 11
Versions:
- Node.js : v16.13.0
- npm : 8.1.0
- discord.js : ^13.7.0
Packages:
- "@discordjs/builders": "^0.13.0",
- "@discordjs/rest": "^0.4.1",
- "discord-api-types": "^0.32.1"
Scopes:
- applications.commands
- bot
Bot permission:
- administrator
I was following the tutorial from the discord docs and building slash commands for my bot. I was able to register the commands and get the success message, then /ping the bot and get a response. I committed and walked away. A few hours later I come back to start building more commands and the bot doesn't respond to /ping anymore. In fact, this block of code is not being reached at all:
client.on('interactionCreate', async interaction => {
if (!interaction.isCommand()) return;
const command = client.commands.get(interaction.commandName);
if (!command) return;
try {
await command.execute(interaction);
} catch (error) {
console.error(error);
await interaction.reply({ content: 'There was an error while executing this command!', ephemeral: true });
}
});
I've tried:
- reinstall npm
- reinstall discord.js
- kick the bot and redo the scopes and permissions (not changing them)
- wait a few hours for the api to catch up registering the slash commands
- tried
interactioninstead ofinteractionCreate
Notes:
I am using these intents :
FLAGS.GUILDS, FLAGS.GUILD_MESSAGES, FLAGS.GUILD_EMOJIS_AND_STICKERSI am using .mjs files for the commands, and
import()syntax to register them. It was in a working state with those things when I left it. I've also tried reverting torequiresince the docs use that but that did not change anything.I did once get the error described here but it went away and I now see
Successfully registered application commandswhen I deploy the commands.UPDATE:
- The
requiresyntax for importing files and registering events and commands seems to work. ES6 modules do not seem to let me register commands.