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 toolkit12mo 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.
</Nexus_Prime>
</Nexus_Prime>12mo ago
node: v18.15.0
treble/luna
treble/luna12mo ago
seems like your client isnt logged in you should also use a separate deploy file to deploy commands
</Nexus_Prime>
</Nexus_Prime>12mo ago
but how would I not be logged in if the guild returns the data? memory: 🔥
treble/luna
treble/luna12mo ago
the guilds intent is a pretty useful intent you can set up sweepers
</Nexus_Prime>
</Nexus_Prime>12mo ago
ok, i gonna try..
d.js docs
d.js docs12mo ago
guide Miscellaneous: Sweeping caches read moreguide Creating Your Bot: Creating slash commands read more
</Nexus_Prime>
</Nexus_Prime>12mo ago
@luna🌈 @qjuh worked, tks!