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
Hyper2y ago
I'd like to avoid using preconditions if possible
Solution
Ben
Ben2y 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
Hyper2y ago
Because that would be a hassle Okay
Ben
Ben2y ago
Technically that is using a precondition btw. Its just one of the premade ones that come with sapphire.
Hyper
Hyper2y ago
Ok
Ararou 🍭
Ararou 🍭2y ago
yeah uh kinda still fucks up stuff in dms with the bot
Ben
Ben2y 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
Ben2y 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
Ben2y 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