Cannot read properties of null on guild.commands.create

sup, see my code:
(this.client.guilds.fetch(process.env.GUILD_TEST)).then(g => {
g.commands.create(command.data);
})
(this.client.guilds.fetch(process.env.GUILD_TEST)).then(g => {
g.commands.create(command.data);
})
command.data and g isn't undefined. error:
{myPrivatePaths}/node_modules/discord.js/src/managers/ApplicationCommandManager.js:52
return Routes.applicationGuildCommands(this.client.application.id, this.guild?.id ?? guildId);
^

TypeError: Cannot read properties of null (reading 'id')
at GuildApplicationCommandManager.commandPath ({myPrivatePaths}/node_modules/discord.js/src/managers/ApplicationCommandManager.js:52:70)
{myPrivatePaths}/node_modules/discord.js/src/managers/ApplicationCommandManager.js:52
return Routes.applicationGuildCommands(this.client.application.id, this.guild?.id ?? guildId);
^

TypeError: Cannot read properties of null (reading 'id')
at GuildApplicationCommandManager.commandPath ({myPrivatePaths}/node_modules/discord.js/src/managers/ApplicationCommandManager.js:52:70)
what's happening?
8 Replies
d.js toolkit
d.js toolkit2y ago
• 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.
Sexus Prime
Sexus PrimeOP2y ago
node: v18.15.0
treble/luna
treble/luna2y ago
seems like your client isnt logged in you should also use a separate deploy file to deploy commands
Sexus Prime
Sexus PrimeOP2y ago
but how would I not be logged in if the guild returns the data? memory: 🔥
treble/luna
treble/luna2y ago
the guilds intent is a pretty useful intent you can set up sweepers
Sexus Prime
Sexus PrimeOP2y ago
ok, i gonna try..
d.js docs
d.js docs2y ago
guide Miscellaneous: Sweeping caches read moreguide Creating Your Bot: Creating slash commands read more
Sexus Prime
Sexus PrimeOP2y ago
@luna🌈 @qjuh worked, tks!
Want results from more Discord servers?
Add your server