Is there a way to make global app commands (/) only work via DMs?

I know how to prevent global commands from showing up in DMs but I'm wanting the other way around.
13 Replies
d.js toolkit
d.js toolkit2y ago
• What's your exact discord.js npm list discord.js and node node -v version? • Post the full error stack trace, not just the top part! • Show your code! • Explain what exactly your issue is. • Not a discord.js issue? Check out #useful-servers.
Squid
Squid2y ago
No, it's not possible You would have to deploy them globally, then manually return if the channel is not DM-based
Erin
ErinOP2y ago
Alright ty If I wanted to exclude 2 commands from only being able to run via DMs (meaning they can be ran in a guild) this would be the correct code, right?
if (dmCommand.commandName != 'invite' && dmCommand.commandName != 'ping' && dmCommand) return interaction.reply('This command can only be ran in DMs.');
if (dmCommand.commandName != 'invite' && dmCommand.commandName != 'ping' && dmCommand) return interaction.reply('This command can only be ran in DMs.');
Cause it is not working. I tried running /ping and it is still saying that the command can only be ran via DMs. These would be the only 2 commands.
monbrey
monbrey2y ago
Isnt dmCommand always going to be truthy
Erin
ErinOP2y ago
I removed that and attempted again and same thing.
monbrey
monbrey2y ago
So what is dmCommand here?
Erin
ErinOP2y ago
That is all of my slash commands that I only want to be run in DMs
monbrey
monbrey2y ago
So its an array?
Erin
ErinOP2y ago
Yes ping me whenever someone has an idea. thanks in advance.
monbrey
monbrey2y ago
Well arrays don't have properties like that. I'm not sure what you're attempting anymore. Would need to see far more surrounding code for context @dudethatserin
Erin
ErinOP2y ago
I’m trying to make it so only the ping and invite commands can be used in guilds where other global application commands can only be used in DMs. https://github.com/DudeThatsErin/Omnivore-Bot/blob/main/index.js this is my entire index.js file. Bot is going to be open source.
monbrey
monbrey2y ago
I'd just check interaction.commandName And if it's one of those two, let it be used
Erin
ErinOP2y ago
Alright I’ll try that
Want results from more Discord servers?
Add your server