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

360
Visualizações
(closed) How to get the autocomplete query in discord.js

Recently, I came to know about the Autocomplete feature in discord.js@13.6.0 and I wanted to try it out. I was able to do the basics by seeing the answer on this post => How to use AutoComplete in Discord.js v13

I was able to set up the autocomplete and was also able to respond to the autocomplete interaction by using:

client.on('interactionCreate', interaction => {
   if (interaction.isAutocomplete()) {
      interaction.respond([
         {
            name: 'Command Help',
            value: 'help'
         }
      ]);      
   }
})

But my doubt is that is there any way to get the string which the user typed which caused the autocomplete interaction. For example: there is an array of options, and based on what the user typed, I would be able to filter the options and then show the correct ones?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Yes you can do so very easily by using

interaction.options.getFocused()

this will return whatever the user is currently typing but if you do

interaction.options.getFocused(true)

it will return an object with the the name of the option and the value that the user has typed so far.

You can find the documentation here

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