#How to publish guild specific commands while having global commands

49 messages · Page 1 of 1 (latest)

ancient hearth
#

I have two folders for two categories of commands. One folder named "commands" for global commands and one folder named "guildCommands" for commands that is for only some guilds.

grave dock
#

• 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.

neon depot
#

do separate rest requests

ancient hearth
neon depot
#

rest.put(Routes.applicationCommands(clientId), { body })
and rest.put(Routes.applicationGuildCommands(clientId, guildId), { body })

ancient hearth
neon depot
ancient hearth
neon depot
#

why 🤔

#

you should

hasty rockBOT
#

guide Creating Your Bot: Registering commands - Command deployment script
read more

ancient hearth
#

the tutorial i started showed me like this

neon depot
#

well don't follow that

#

use discordjs.guide

#

it's maintained by discord.js developers and the community, and kept updated

ancient hearth
#

ok

#

could you let me know what i am using rn

ancient hearth
#

await client.application.commands.set(client.commands);

neon depot
#

you are using client.application which requires the bot to be logged in

#

this is not good practice

ancient hearth
#

ohh

#

so on reading that guide i had few doubt

#

once i create my deploy-commands.js

#

how do i make it run automatically when my bot is added to a new server

neon depot
#

what why

ancient hearth
#

let me rephrase

neon depot
#

which requires the bot to be logged in

#

this also usually comes with setting in ready event

ancient hearth
neon depot
#

no

#

that's terrible

#

setting in ready event is not needed

ancient hearth
neon depot
#

you only need to deploy when commands are updated

neon depot
#

why

#

just use rest

#

doesn't even need the client logged in

ancient hearth
#

so will the new server automatically get it ?

neon depot
#

yes the new server will get the global commands

ancient hearth
#

ok

#

thanks

#

will try and update

neon depot
#

👍

ancient hearth
ancient hearth
# neon depot 👍

i need to import my set of commands into this. how can i make it take the details from each file and auto create the set of commands. edit: done. found a method