#Implementing slash commands with options - choices
50 messages · Page 1 of 1 (latest)
• 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.
Creating Your Bot: Command handling
Unless your bot project is a small one, it's not a very good idea to have a single file with a giant if/else if chain for commands. If you want to implement features into your bot and make your development process a lot less painful, you'll want to implement a command handler. Let's get started...
read more
Implementing slash commands with options - choices
How is your command handler set up? You're not using the guide's since it uses the builders
You're not setting the options on the builders that are being deployed
i initially used a yt tutorial which depended on client.application . then i switched to this rest
thread i made for that
https://discord.com/channels/222078108977594368/1030971149598871552
like this ?
That's one possibility for adding a string option with choices
how can i get it to take my options array
.addStringOption(globalCommand.options)
will this suffice
I don't think you can mix and match JSON with builders
You should commit to one way or the other
Issue is i am confused myself
on what i am using
that tutorial is what i started from
rn i am going thro https://discordjs.guide/interactions/slash-commands.html#choices
You may prefer to deploy { name, description, options } objects through REST or the DJS ApplicationCommandManager
Otherwise, you should use builders in your exported command objects like the guide shows, including for the name and description
Mapping the builder to its toJSON() method produces an object
You can bypass builders and just make your own objects
i really have no idea what builders are . am i using them in my code rn ?
This class is a builder
so instead of that what should i do
new SlashCommandBuilder().setName(...).setDescription(...).toJSON() is about the same as { name, description }
understood
Your end goal is just to return a { name, description, options } object
let me try something. i didnt know that that builder was the issue
i assumed it was just so the server knows that command exist
didnt know it needed all the options too.looking back it makes sense that way
thanks . will update if anything comes up
The builder isn't an issue, but if you use it, your options have to work like shown in the guide
Otherwise, you have to find a workaround
will see