Preventing Commands in DMs

HHyper2/25/2023
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
HHyper2/25/2023
I'd like to avoid using preconditions if possible
Solution
BBen2/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 that
HHyper2/25/2023
Because that would be a hassle Okay
BBen2/25/2023
Technically that is using a precondition btw. Its just one of the premade ones that come with sapphire.
HHyper2/25/2023
Ok
AArarou2/25/2023
yeah uh kinda still fucks up stuff in dms with the bot
BBen2/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
BBen2/25/2023
Thats odd. Is your code on github?
AArarou2/25/2023
no it’s closed source the repo for it is private but I can show an example
BBen2/25/2023
Can you reproduce it in a small bot and share the code for that?
AArarou2/25/2023
AArarou2/25/2023
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

Looking for more? Join the community!

Want results from more Discord servers?
Add your server
Recommended Posts
autoModerationActionExecution EventDoes Sapphire not emit the Discord.js `autoModerationActionExecution` event? The following code doeHelp canceling a commandHere the code I have for a simple reminder command.https://pastebin.com/crRSdjEn. It works but id liHow to check if the bot has Permission X inside of the server? For example VIEW_AUDIT_LOGIn a listenerWhat parameter do I pass to the run method in my GuildCreate listener?Problem with this.container.stores.get().get();Code:InteractionCreate fileCan I easily create a listener for `interactionCreate`? I need it for some UI Abilities, and I am noHow to Create Threads?I dont get how to create threads programmatically. Please helpCommand infodoes sapphire have a built in command info funtions so we can get for example the aliases of a commaargs.pick("member")using `args.pick("member")`, is it intended to get the member even if you just provide 1 letter of twhy does this not work in sapphireindex.js ```js const { util } = require("./utils"); const { container } = require("@sapphire/framewoThis code is not running on sapphire```js const { Listener } = require("@sapphire/framework"); const { ActivityType } = require("discordBot stalls while registering commandsMy bot was working fine yesterday after noticing the new Cog section of the documentation (really coHow to edit an Embed(Documentation isn't working)Hi. Trying to make a discord bot that will send a message to a specific channel on startup. I have Schdeduler SQS Options in index.tsWhere can I find what options I have to pass for the SQS Version of the Scheduled Task? I cant seemType T[P] does not satisfy constraint Option<any>When building my project on my ubuntu server, with tsc, I get those errors, its more a TS issue thanWill using the new plugin-utilities-store enable HMR for this Helper files?As stated in the title: If i add some functions to the util store will they be reloaded on change wi"Send" does not exist on type "channel"Hi. Trying to make a discord bot that will send a message to a specific channel on startup. I try tHow can I create a listener for @discordjs/voice states?Title kinda explains itself lol, but how can I convert things like ```javascript const { VoiceConnecHow to delete interaction buttons?Hello@sapphire/shapeshift (?) crashes bot when trying to send embed with description exceeding 4096 charshi, so I have a message cmd which shows info on a github user in a nice embed. when bot sends the in