#Implementing slash commands with options - choices

50 messages · Page 1 of 1 (latest)

sand wharf
#

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.

fleet basalt
#

• 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.

sand wharf
pearl ermineBOT
#

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

sand wharf
#

Implementing slash commands with options - choices

zinc mauve
#

How is your command handler set up? You're not using the guide's since it uses the builders

zinc mauve
#

You're not setting the options on the builders that are being deployed

sand wharf
zinc mauve
#

That's one possibility for adding a string option with choices

sand wharf
#

.addStringOption(globalCommand.options)

#

will this suffice

zinc mauve
#

I don't think you can mix and match JSON with builders

#

You should commit to one way or the other

sand wharf
#

Issue is i am confused myself

#

on what i am using

#

that tutorial is what i started from

zinc mauve
#

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

sand wharf
#

for deployment

#

where commands

#

i think this full is on REST

zinc mauve
#

Mapping the builder to its toJSON() method produces an object
You can bypass builders and just make your own objects

sand wharf
#

i really have no idea what builders are . am i using them in my code rn ?

zinc mauve
#

This class is a builder

sand wharf
#

so instead of that what should i do

zinc mauve
#

new SlashCommandBuilder().setName(...).setDescription(...).toJSON() is about the same as { name, description }

sand wharf
#

understood

zinc mauve
#

Your end goal is just to return a { name, description, options } object

sand wharf
#

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

zinc mauve
#

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

sand wharf
#

will see

sand wharf
#

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