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
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Febkosq8
Febkosq82y ago
Febkosq8
Febkosq82y ago
d.js docs
d.js docs2y ago
guide 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
Squid
Squid2y ago
How is your command handler set up? You're not using the guide's since it uses the builders
Febkosq8
Febkosq82y ago
Squid
Squid2y ago
You're not setting the options on the builders that are being deployed
Febkosq8
Febkosq82y ago
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
Febkosq8
Febkosq82y ago
Febkosq8
Febkosq82y ago
like this ?
Squid
Squid2y ago
That's one possibility for adding a string option with choices
Febkosq8
Febkosq82y ago
how can i get it to take my options array .addStringOption(globalCommand.options) will this suffice
Squid
Squid2y ago
I don't think you can mix and match JSON with builders You should commit to one way or the other
Febkosq8
Febkosq82y ago
Issue is i am confused myself on what i am using that tutorial is what i started from
Febkosq8
Febkosq82y ago
discord.js Guide
Imagine a guide... that explores the many possibilities for your discord.js bot.
Squid
Squid2y ago
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
Febkosq8
Febkosq82y ago
for deployment
Febkosq8
Febkosq82y ago
where commands
Febkosq8
Febkosq82y ago
i think this full is on REST
Squid
Squid2y ago
Mapping the builder to its toJSON() method produces an object You can bypass builders and just make your own objects
Febkosq8
Febkosq82y ago
i really have no idea what builders are . am i using them in my code rn ?
Squid
Squid2y ago
This class is a builder
Febkosq8
Febkosq82y ago
so instead of that what should i do
Squid
Squid2y ago
new SlashCommandBuilder().setName(...).setDescription(...).toJSON() is about the same as { name, description }
Febkosq8
Febkosq82y ago
understood
Squid
Squid2y ago
Your end goal is just to return a { name, description, options } object
Febkosq8
Febkosq82y ago
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
Squid
Squid2y ago
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
Febkosq8
Febkosq82y ago
will see
Febkosq8
Febkosq82y ago
Febkosq8
Febkosq82y ago
i tried this
Febkosq8
Febkosq82y ago
Febkosq8
Febkosq82y ago
Febkosq8
Febkosq82y ago
it has the choices in it i redeployed the commands but still no options show up
Febkosq8
Febkosq82y ago
Febkosq8
Febkosq82y ago
i just deleted all global and guild commands and redeployed and it showed up so thats working now