Implementing slash commands with options - choices
I am trying to add options to my existing slash command code but on testing discord does not show me the options . I already tried re deploying my guild commands.
36 Replies
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
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
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
discord.js Guide
Imagine a guide... that explores the many possibilities for your discord.js bot.
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 descriptionfor deployment
where commands
i think this full is on REST
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 }
objectlet 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
i tried this
it has the choices in it
i redeployed the commands
but still no options show up
i just deleted all global and guild commands and redeployed and it showed up
so thats working now