How to add options to a slash command?
How would I add options for people to input data when making a slash command? This is what I have so far.
22 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!discord.js Guide
Imagine a guide... that explores the many possibilities for your discord.js bot.
What does the last 2 lines do there?
setDMPermission is to not allow the command be run in the bot DMs
setDefaultMemberPermissions permission that is allowed to execute the command
Ok, I get this error now?
User must be user
Oh no caps?
Yes
Ok
Is there a way to make it so only certain roles can do it instead of permissions?
As far as i know, no. But it may be possible
Ok, how would I now get the user that they inputted when it replies, for example pinging them in the ping message.
const userToBePinged = interaction.options.getUser('user') ?? "";
would that give me the id or what?
Is the user object i think
Put a console.log to make sure
how do i put a log in?
console.log(userToBePinged)
Aaah so how would I put the userToBePinged.id into the interaction.reply
Template literals (Template strings)
Template literals are literals delimited with backtick (`) characters, allowing for multi-line strings, string interpolation with embedded expressions, and special constructs called tagged templates.
nvm figured it out
sorry
you can check if use has a role that can use the command in your execute