Setting different commands for different types of servers.
Hello there, so i have a few server types.
the user must /register before being able to see all the commands.
Seperate kinds of servers should have seperate set of commands, and they should not be able to see each other's commands.
for example (if you didnt understand) :
- A server adds my bot.
- They should initially only be able to see the /register command, and should not be able to see any other commands until they register.
- They can register the type of server. for example: government server / mafia server
- Government can only see gov related commands
- mafia can see mafia related commands etc..
how do i make it update commands conditionally?
15 Replies
- 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!
- ✅
Marked as resolved by OPuse guild-specific commands
this is how im doing it,
can you elaborate further? how can i do it
this is for just one guild
you'd probably have to make a custom command handler for commands with separated folders for different types
use that code to only register the /register command
im doing it like this
then make a different one, getting all the guilds with their id and registering the commands appropriate to their type
criminal folder has criminal specific stuff (which is a faction type for a game)
same with law
factions are common cmds
just read my previous messages, and if you don't understand a specific part i'll elaborate further
ok i'll try something and be back
so i did what you said, all works fine except, i wrote this refresh commands module based on faction type
however,, sometimes it compltely deletes all the faction commands (im trying to refresh them)
whilst sometimes it works perfect
i suspect its due to the async nature but im unsure
that's pretty weird
It's likely that the for loop isn't finishing before trying to refresh your commands, meaning the
commands
array is empty
You could use Promise.all()
with a map insteadthat worked, thanks a lot.