Slash command error
why is it showing this when i run
/wave
in chat?
main code:
require('dotenv').config();
const { Client, IntentsBitField } = require('discord.js');
const client = new Client({
// make sure all 3 intents are enabled in developer portal
intents: [
IntentsBitField.Flags.Guilds,
IntentsBitField.Flags.GuildMembers,
IntentsBitField.Flags.GuildMessages,
IntentsBitField.Flags.MessageContent,
],
});
client.on('ready' , (c) => {
console.log(
${c.user.tag} is online.);
});
client.on('interactionCreate', (interaction) => {
if (!interaction.isChatInputCommand()) return;
if (interaction.commandName === 'wave') {
interaction.reply('Hey👋!');
}
});
client.login(process.env.TOKEN);
register command code:
require('dotenv').config();
const { REST , Routes} = require ('discord.js');
const commands = [
{
name: 'wave',
description: 'wave to the bot :)',
},
];
const rest = new REST({version: '10'}).setToken(process.env.TOKEN);
(async () => {
try {
console.log('Registering slash commands...');
await rest.put (
Routes.applicationGuildCommands(process.env.CLIENT_ID, process.env.GUILD_ID),
{body: commands}
);
console.log('Slash commands were registered successfully!');
} catch (error){
console.log(
There was an error: ${error});
}
})();
4 Replies
- What's your exact discord.js
npm list discord.js
and node node -v
version?
- Post the full error stack trace, not just the top part!
- Show your code!
- Explain what exactly your issue is.
- Not a discord.js issue? Check out #useful-servers.
- Issue solved? Press the button!have you used a website to host your bot before?
nope..
usually i dont need to
op left the server