Preventing Commands in DMs

How do you prevent commands from being used in DMs? Message commands.
Solution:
Add runIn: 'GUILD_ANY' to your command options. This will only the command to be run in guild channels. If you want to specify a type of channel there are opttions for that
Jump to solution
13 Replies
Hyper
Hyperβ€’2y ago
I'd like to avoid using preconditions if possible
Solution
Ben
Benβ€’2y ago
Add runIn: 'GUILD_ANY' to your command options. This will only the command to be run in guild channels. If you want to specify a type of channel there are opttions for that
Hyper
Hyperβ€’2y ago
Because that would be a hassle Okay
Ben
Benβ€’2y ago
Technically that is using a precondition btw. Its just one of the premade ones that come with sapphire.
Hyper
Hyperβ€’2y ago
Ok
πŸŽƒ ararou!
πŸŽƒ ararou!β€’2y ago
yeah uh kinda still fucks up stuff in dms with the bot
Ben
Benβ€’2y ago
You're gonna need to be more specific than that. Whats the problem?
πŸŽƒ ararou!
πŸŽƒ ararou!β€’2y ago
when ever the command is still ran in DMs, it still crashes it even when that’s added
Ben
Benβ€’2y ago
Thats odd. Is your code on github?
πŸŽƒ ararou!
πŸŽƒ ararou!β€’2y ago
no it’s closed source the repo for it is private but I can show an example
Ben
Benβ€’2y ago
Can you reproduce it in a small bot and share the code for that?
πŸŽƒ ararou!
πŸŽƒ ararou!β€’2y ago
πŸŽƒ ararou!
πŸŽƒ ararou!β€’2y ago
sure once I get this done rq or it could also be a chance of discord.js changes since I’m on v14 wait nvm I’ll just add an check to the preconditions or use β€˜GuildOnly’ in preconditions: [] yea using preconditions: ['GuildOnly', 'PreconditionName'] works for me
Want results from more Discord servers?
Add your server