Unable to create slash commands

This is my code:
client.application.commands.create({
name: 'test',
description: 'devs',
})
.then(console.log)
.catch(console.error);
client.application.commands.create({
name: 'test',
description: 'devs',
})
.then(console.log)
.catch(console.error);
This is the error Im getting
Uncaught TypeError TypeError: Cannot read properties of null (reading 'commands')
Uncaught TypeError TypeError: Cannot read properties of null (reading 'commands')
15 Replies
d.js toolkit
d.js toolkit15mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - 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!
treble/luna
treble/luna15mo ago
the client hasnt logged in yet
d.js docs
d.js docs15mo ago
guide Creating Your Bot: Registering slash commands read more
treble/luna
treble/luna15mo ago
use that instead
Carbon
CarbonOP15mo ago
thanks it works is there a way to add options to it
commands.create({
name: 'test',
description: 'devs',
})
commands.create({
name: 'test',
description: 'devs',
})
treble/luna
treble/luna15mo ago
pass in the options array and also use a separate deploy script
Carbon
CarbonOP15mo ago
how do I do that Just started learning djs 2 days back
treble/luna
treble/luna15mo ago
read and if you're new i would recommend using builders
Carbon
CarbonOP15mo ago
what are builders
Carbon
CarbonOP15mo ago
I used builders first but I didn't know what to do after that
const data = new SlashCommandBuilder()
.setName("promote")
.setDescription("promote a user to the next rank.")
.addStringOption(option =>
option.setName('user_id')
.setDescription('test hi')
.setRequired(false));
const data = new SlashCommandBuilder()
.setName("promote")
.setDescription("promote a user to the next rank.")
.addStringOption(option =>
option.setName('user_id')
.setDescription('test hi')
.setRequired(false));
I couldn't find anything for that either
d.js docs
d.js docs15mo ago
method SlashCommandBuilder#toJSON() Returns the final data that should be sent to guide Home: What's new read more
Carbon
CarbonOP15mo ago
how do I use it though
treble/luna
treble/luna15mo ago
i would recommend reading the guide it covers everything you need
Carbon
CarbonOP15mo ago
alright
Want results from more Discord servers?
Add your server