#slash commands and commands in general
41 messages · Page 1 of 1 (latest)
• 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.
my discord.js version is 14.7.1 and my node is 18.12.1
my issue is: my commands is not working in my discord server and i dont know why, already online in the discord server and not working at all.
my code: https://sourceb.in/1sANpHjeEP
you are missing the client.login(TOKEN) bit or did you redact it?
i redacted
the cliient.on(message) bit should be outside of the client.on(ready) block
if it is inside it will only listen for the split second when the client is ready
you need to specify at least 1 intent
the code stopped working xd
like that?
^
try: const client = new Discord.Client({ intents: [GatewayIntentBits.Guilds] });
btw i see you are at the beginning: consider using slash commands
like that
he hasn't defined gatewayintentbits
still not working :/
type Discord.GatewayIntentBits.Guilds instead
add const { GatewayIntentBits } = Discord; at the beginning or use const client = new Discord.Client({ intents: [Discord.GatewayIntentBits.Guilds] });
that worked
Maybe a look at the guide will help you too: https://discordjs.guide/creating-your-bot/main-file.html#running-your-application
i will add
Perfect
that was what @fathom veldt typed, they made the same suggestion
oh ok
as he said, I recommend you to use slash commands
sorry for the ping btw
Slash commands are also covered by the official guide: https://discordjs.guide/creating-your-bot/slash-commands.html
console log your command variable
slash commands require a different setup, please refer to the guide first
Of course it wont.
1.- you didnt make a slashcommand
2.- message isnt a valid event
And you are missing GuildMessages and MessageContent intent to use prefix commands
At this point just check djs guide and learn how slashcommands work
you are looking for https://discord.js.org/#/docs/discord.js/main/class/Client?scrollTo=e-messageCreate the messageCreate event
totally agree - here ist the link again: https://discordjs.guide/creating-your-bot/slash-commands.html