#Autocomplete options - what is the value property for?

11 messages · Page 1 of 1 (latest)

opal sedge
#

A related question was asked here: https://discord.com/channels/222078108977594368/1035366885891506278

I'm trying to do the same thing as them (show just one word as an autocomplete option, but when they select the option, it only appends it to the end of their current input), but I have a more specific question. Autocomplete options take an object with required properties name and value, but usually people set them to the same thing, so they don't care about the differences between the properties. Like this:

interaction.respond([{
    name: "hello",
    value: "hello",
}]);

What I assumed at first was that the name property is displayed to the user, but when they click the option, the value property would replace their input. But that didn't work.

After experimenting, I found that the value property actually has no effect whatsoever on the autocomplete interaction. These next two examples have the exact same results - the user sees the name property ("hello") when viewing the autocomplete options, and when clicking it, their input is completely replaced by the name property ("hello").

interaction.respond([{
    name: "hello",
    value: "hello world",
}]);

and

interaction.respond([{
    name: "hello",
    value: "jblaklqwerpoij,a,l1!@#LTQRqnwj",
}]);

So what is the point of the value field? Or is this a bug?

regal prawn
#

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

onyx steppe
#

it's what the bot receives for the value

#

name is what shows up in the ui, value is what shows up in the interaction

opal sedge
#

hmm i think i see

onyx steppe
#

it's the same thing as how choices work

opal sedge
#

but so if I had an option with name "hello", and the user manually types the word "hello", would the bot still receive the value field?

#

if the user didn't click the autocomplete choice?

onyx steppe
#

no, it'll use the user's input literally

opal sedge
#

oh ok

#

too bad then