Can't get any of this to work. #1022
-
I have followed command-handling, creating commands and event-handling. It always ends up the same, my bot comes online but is unable to respond to any command. The latest I tried was this: Please follow that guide to a note and tell me you can get it working. |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 10 replies
-
My bot has application.command rights |
Beta Was this translation helpful? Give feedback.
-
Sure, here is the latest one I have by following https://github.com/discordjs/guide/blob/main/guide/interactions/registering-slash-commands.md index.jsconst fs = require('fs'); const client = new Client({ intents: [Intents.FLAGS.GUILDS] }); client.commands = new Collection(); for (const file of commandFiles) { client.once('ready', () => { client.on('interactionCreate', async interaction => {
}); client.login(token);deploy-commands.js const fs = require('fs'); const commands = []; for (const file of commandFiles) { const rest = new REST({ version: '9' }).setToken(token); (async () => {
})();ping.js(under commands folder) const { SlashCommandBuilder } = require('@discordjs/builders'); const data = new SlashCommandBuilder()
|
Beta Was this translation helpful? Give feedback.
-
I have made a repository: I would greatly appreciate if someone could look at it and find out why my commands are not working. |
Beta Was this translation helpful? Give feedback.
-
You're not executing the commands on the Given that you're attaching a module.exports = {
name: 'interactionCreate',
execute(interaction) {
console.log(`${interaction.user.tag} in #${interaction.channel.name} triggered an interaction.`);
if (interaction.isCommand()) {
const command = interaction.client.commands.get(interaction.commandName);
command?.execute(interaction);
}
},
}; |
Beta Was this translation helpful? Give feedback.
-
Running node deploy-commands.js opens up a terminal for half a second, then closes. S[10002]: Unknown Application |
Beta Was this translation helpful? Give feedback.
You're not executing the commands on the
interactionCreate
listener.Given that you're attaching a
commands
property to yourclient
, you can do something like this (replace the contents of yourinteractionCreate.js
file with this):