Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

159
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda