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

166
Views
How to display YouTube suggestions as interaction options

How could I display YouTube autofill suggestions while a user is inputting a string? I'm using DisTube and the searchSongs option but that only affects the result of already inputting a text. I've seen bots such as Soul Music effectively pull it off so it's clearly possible but I'm not sure how they exactly did it.

interaction displaying query as YouTube search suggestions

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

0

This is achieved with the help of something called Autocomplete in discord.js. It's actually pretty simple to do something like this. The first step is to declare an autocomplete command. This can be done in the SlashCommandBuilder by using the option .setAutocomplete(). An example:

const data = new SlashCommandBuilder()
    .setName('command-name')
    .setDescription('command-description')
    .addStringOption(option => {
        option
            .setName('option-name')
            .setDescription('option-description')
            .setAutocomplete(true)
    })

Then, you just have to create an event listener for the interactionCreate event, and then when it fires, check if the interaction was an Autocomplete request and respond with a value. An example:

client.on('interactionCreate', (interaction) => {
    if (!interaction.isAutocomplete()) return
    const enteredValue = interaction.options.getFocused()
    const values = [
        {
          name: 'option-name',
          value: 'option-value',
        }
    ]
    interaction.respond(values)
})

If you want to learn more about the Autocomplete feature, I'd suggest you go here => Autocomplete | discord.js

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!