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
Hyper16mo ago
I'd like to avoid using preconditions if possible
Solution
Ben
Ben16mo 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
Hyper16mo ago
Because that would be a hassle Okay
Ben
Ben16mo ago
Technically that is using a precondition btw. Its just one of the premade ones that come with sapphire.
Hyper
Hyper16mo ago
Ok
Ararou
Ararou16mo ago
yeah uh kinda still fucks up stuff in dms with the bot
Ben
Ben16mo ago
You're gonna need to be more specific than that. Whats the problem?
Ararou
Ararou16mo ago
when ever the command is still ran in DMs, it still crashes it even when that’s added
Ben
Ben16mo ago
Thats odd. Is your code on github?
Ararou
Ararou16mo ago
no it’s closed source the repo for it is private but I can show an example
Ben
Ben16mo ago
Can you reproduce it in a small bot and share the code for that?
Ararou
Ararou16mo ago
Ararou
Ararou16mo 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