S-IAF
Join ServerSapphire - Imagine a framework
sapphire-support
Preventing Commands in DMs
HHyperfire2/25/2023
How do you prevent commands from being used in DMs? Message commands.
HHyperfire2/25/2023
I'd like to avoid using preconditions if possible
Solution
BBen8552/25/2023
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 thatHHyperfire2/25/2023
Because that would be a hassle
HHyperfire2/25/2023
Okay
BBen8552/25/2023
Technically that is using a precondition btw. Its just one of the premade ones that come with sapphire.
HHyperfire2/25/2023
Ok
AArarou2/25/2023
yeah uh
AArarou2/25/2023
kinda still fucks up stuff in dms with the bot
BBen8552/25/2023
You're gonna need to be more specific than that. Whats the problem?
AArarou2/25/2023
when ever the command is still ran in DMs, it still crashes it even when that’s added
BBen8552/25/2023
Thats odd. Is your code on github?
AArarou2/25/2023
no it’s closed source
AArarou2/25/2023
the repo for it is private but I can show an example
BBen8552/25/2023
Can you reproduce it in a small bot and share the code for that?
AArarou2/25/2023

AArarou2/25/2023
sure
AArarou2/25/2023
once I get this done rq
AArarou2/25/2023
or it could also be a chance of discord.js changes
AArarou2/25/2023
since I’m on v14
AArarou2/25/2023
wait nvm
AArarou2/25/2023
I’ll just add an check to the preconditions
AArarou2/25/2023
or use ‘GuildOnly’ in preconditions: []
AArarou2/25/2023
yea using
preconditions: ['GuildOnly', 'PreconditionName']
works for me