Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

256
Views
Create a suggested choice in string options in Discord.JS

For example, if I apply my question to this code from the Discord.JS guide:

const data = new SlashCommandBuilder()
    .setName('gif')
    .setDescription('Sends a random gif!')
    .addStringOption(option =>
        option.setName('category')
            .setDescription('The gif category')
            .setRequired(true)
            .addChoice('Funny', 'gif_funny')
            .addChoice('Meme', 'gif_meme')
            .addChoice('Movie', 'gif_movie'));

This works great, but what if I wanted the choices to be optional, without using a select menu? (i.e., the user can pick "Funny", "Meme", "Movie", or pick their own.)

For my use case, I want to suggest common reasons for mutes:

const { SlashCommandBuilder } = require("@discordjs/builders")

const data = new SlashCommandBuilder()
        .setName("mute")
        .setDescription("Mute/timeout someone!")
        .addUserOption(option => 
            option.setName("user")
                .setDescription("The user to timeout"))
                .setRequired(true)
        .addStringOption(option =>
            option.setName("duration")
                .setDescription("The duration of the timeout")
                .setRequired(true)
                .addChoice("60 sec.", "1")
                .addChoice("5 min.", "2")
                .addChoice("10 min.", "3")
                .addChoice("1 hr.", "4")
                .addChoice("1 day", "5")
                .addChoice("1 week", "6")
        )
        .addStringOption(option =>
            option.setName("reason")
                .setDescription("The reason for the timeout")
                .setRequired(true)
                // add optional choices like "Posting memes in #general", etc., but also let them type their own reasons
        )

For some reason, the docs have absolutely no information about these new classes. I can't find them.

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

As someone said on a different platform, autocorrect lets you write your own input anyway. Also, I found the Builders docs: https://discord.js.org/#/docs/builders/stable/general/welcome

about 4 years ago · Juan Pablo Isaza Report

0

Unfortunately, this isn't possible the way you want to do it. Straight from https://discordjs.guide/interactions/registering-slash-commands.html#option-types/ : Warning about registering slash commands

Of course, there might be other workarounds that I don't know about.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!