How to add support for private slash commands
Not a big Discord user so lots of common stuff I don't know. But I've made a bot for use just in one channel with a couple of friends. I have slash commands working and I've experimented enough to send and receive DMs.
But now I want to add support slash commands in DMs. I can't seem to find the next step via Google, the official docs, Stack Overflow, searching this discord, or asking AI chatbots.
Do I have to modify some stuff on my bot's dev page? Pass some more settings in
new Client()
in my bot code? Or both?8 Replies
- What's your exact discord.js
npm list discord.js
and node node -v
version?
- Not a discord.js issue? Check out #other-js-ts.
- Consider reading #how-to-get-help to improve your question!
- Explain what exactly your issue is.
- Post the full error stack trace, not just the top part!
- Show your code!
- Issue solved? Press the button!
- ✅
Marked as resolved by OPCan you show how you're deploying your slash commands.
i modified the
deploy-commands.js
from a Coding Train video to add support for multiple commands per module:
i only dug in and grokked enough to do my modsthis is the video that was my starting point: https://www.youtube.com/watch?v=AvQcTjB3gPg
and its repo: https://github.com/CodingTrain/Discord-Bot-Examples/tree/main/01-discordjs
The Coding Train
YouTube
I made a Discord Bot that says Choo Choo
Learn to create a Discord bot using Discord.js in Node.js. This video walks through setting up a node project, creating a Discord application, and writing code for authentication, slash commands, and bot interaction. Code: https://thecodingtrain.com/tracks/discord-bots/discord/coding-a-bot
🚀 Watch this video ad-free on Nebula https://nebula.tv/...
GitHub
Discord-Bot-Examples/01-discordjs at main · CodingTrain/Discord-Bot...
Bot Examples for Fall 2023. Contribute to CodingTrain/Discord-Bot-Examples development by creating an account on GitHub.
Yeah so, the line where you have
Routes.applicationGuildCommands
You'd want to change that to Routes.applicationCommands(client_id)
Or your process.env.CLIENTID anyway
That will deploy them globally, into DMs
You'd also then want to remove them from the guild, so they aren't duplicatedOur guide covers it
ah ok i just found that independently and it's working. this text made me wonder if it is a bit heavy handed
Guild-based deployment of commands is best suited for development and testing in your own personal server. Once you're satisfied that it's ready, deploy the command globally to publish it to all guilds that your bot is in.but i guess not as it's basically a private bot for my friends and one server so thanks everyone!