#autocomplete help

1 messages · Page 1 of 1 (latest)

sacred lake
#

what does the option log as?

limber smelt
#

teh wierd thing is it doesnt

sacred lake
#

it this line of code even reached? add a few more console.logs

#

you also might want to move the require call outside the callback, unless you're dealing with circular requires there's no need to do it here and not at the top

limber smelt
#

wierd

#
if(cmd.inputs.includes('fetch')){if(cmd.inputs.includes('fetch_required')){cmd.data.addNumberOption(option=>option.setName('fetch').setDescription('fetch value').setRequired(true).setAutocomplete(true))}else cmd.data.addNumberOption(option=>option.setName('fetch').setDescription('fetch value').setAutocomplete(true))}
const {fetchAuditLog}=require('../functions')
module.exports={
    name:'get',
    description:'Get audit log entries',
    inputs:'fetch',
    execute(bot,interaction){

    }
}

it shows the autocomplete and all, but doesnt trigger the interaction.isAutocomplete()

sacred lake
#

did you redeploy the command with the autocomplete addition?

limber smelt
#

by redeploy u mean restart the bot?

sacred lake
#

I mean executing your deploy-command script or whatever you use to deploy them

limber smelt
#

so u mean reregistering it

sacred lake
#

yes

limber smelt
#

i did

#

i do it on ready event

sacred lake
#

what happens in discord when you run the command and type something in the autocompleted option?

limber smelt
#

oh, it threw an error:

DiscordAPIError: Invalid Form Body
data.choices[0].value: This field is required
humble tuskBOT
sacred lake
#

has to be { name, value }

limber smelt
#
    {"name":"get","values":[{"name":"All","value":null},{"name":"Guild update","value":1},{"name":"Channel create","value":10}]}

this is what is in the options.json

sacred lake
#

so you need to respond with what's inside "values"

limber smelt
#
DiscordAPIError: Invalid Form Body
data.choices[0]: Only dictionaries may be used in a ModelType
``` ???
sacred lake
#

you did not respond with an array of objects (aka dictionaries in python)

limber smelt
#
{ name: 'All', value: null },
    { name: 'Guild update', value: 1 },
    { name: 'Channel create', value: 10 }

thats what i responded

sacred lake
#

is that inside an array? because you respond with [option]

limber smelt
#

it is array of objects

sacred lake
#

so you are responding with an array of arrays

limber smelt
sacred lake
#

no, drop the brackets

#

option.values is already an array

limber smelt
#

will value: null be a problem?

sacred lake
#

most likely yes

#

though I haven't tested it the api accepts strings/numbers afaik

limber smelt
#

if i provide the fetch auditlog with "null" will it still return all?

#

i mean null in string

sacred lake
#

it's a number option so you can just respond with -1 and handle that in your code

limber smelt
#

ye, if(smt==-1) smt = null