#trimming autocomplete option

1 messages · Page 1 of 1 (latest)

quiet glacier
#

i must be slow because this doesn't work as it says it's still too long

@edittag.autocomplete("tag")
@deltag.autocomplete("tag")
async def autocomplete(inter: disnake.ApplicationCommandInteraction, faq: str):
    _tags = []

    all_tags = await Faq.all()
    for tag in all_tags:
        if (len(tag.question) > 100):
            tag.question = tag.question[:90]
        _tags.append(tag.question)

    values: list[str] = process.extract(faq, _tags, limit=25)
    return [i[0] for i in values]
Ignoring exception in on_application_command_autocomplete
Traceback (most recent call last):
  File "C:\Users\jmart\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\client.py", line 729, in _run_event
    await coro(*args, **kwargs)
  File "C:\Users\jmart\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\ext\commands\interaction_bot_base.py", line 1391, in on_application_command_autocomplete
    await self.process_app_command_autocompletion(interaction)
  File "C:\Users\jmart\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\ext\commands\interaction_bot_base.py", line 1290, in process_app_command_autocompletion
    await slash_command._call_relevant_autocompleter(inter)
  File "C:\Users\jmart\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\ext\commands\slash_core.py", line 687, in _call_relevant_autocompleter
    await inter.response.autocomplete(choices=choices)
  File "C:\Users\jmart\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\interactions\base.py", line 1305, in autocomplete
    await adapter.create_interaction_response(
  File "C:\Users\jmart\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\webhook\async_.py", line 210, in request
    raise HTTPException(response, data)
disnake.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In data.choices.18.name: Must be between 1 and 100 in length.
wooden vale
#

The choice is too long, not the number of choices.

#

As in one of your options is more than 100 characters.

quiet glacier
#

yeah im splicing it tho ?

wooden vale
#

Maybe it's an empty string then?

#

print the list

quiet glacier
#

this doesn't make sense

#
@edittag.autocomplete("tag")
@deltag.autocomplete("tag")
async def autocomplete(inter: disnake.ApplicationCommandInteraction, faq: str):
    _tags = []
    
    all_tags = await Faq.all()
    for tag in all_tags:
        if (len(tag.question) > 100):
            tag.question = tag.question[:90]
        _tags.append(tag.question)
    logging.info(_tags)

yet it's still kicking back the error

#

so i can't even print the list

#
[2024-02-04 21:14:47,800] INFO [root.inactive_tickets:79] Last message: 2024-02-04 18:19:41.753000+00:00 : 2024-02-04 02:14:47.800362+00:00
Ignoring exception in on_application_command_autocomplete
Traceback (most recent call last):
  File "C:\Users\jmart\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\client.py", line 729, in _run_event
    await coro(*args, **kwargs)
  File "C:\Users\jmart\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\ext\commands\interaction_bot_base.py", line 1391, in on_application_command_autocomplete
    await self.process_app_command_autocompletion(interaction)
  File "C:\Users\jmart\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\ext\commands\interaction_bot_base.py", line 1290, in process_app_command_autocompletion
    await slash_command._call_relevant_autocompleter(inter)
  File "C:\Users\jmart\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\ext\commands\slash_core.py", line 687, in _call_relevant_autocompleter
    await inter.response.autocomplete(choices=choices)
  File "C:\Users\jmart\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\interactions\base.py", line 1305, in autocomplete
    await adapter.create_interaction_response(
  File "C:\Users\jmart\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\webhook\async_.py", line 210, in request
    raise HTTPException(response, data)
disnake.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In data.choices.20.name: Must be between 1 and 100 in length.
wooden vale
#

if you print it before the return, it'll be above the error.

quiet glacier
#

i am printing before the return

wooden vale
#

Then scroll up

quiet glacier
#
async def autocomplete(inter: disnake.ApplicationCommandInteraction, faq: str):
    _tags = []
    
    all_tags = await Faq.all()
    logging.info(all_tags)
    for tag in all_tags:
        if (len(tag.question) > 100):
            tag.question = tag.question[:90]
        _tags.append(tag.question)
    logging.info(_tags)

    values: list[str] = process.extract(faq, _tags, limit=25)
    return [i[0] for i in values]
wooden vale
#

No..

#

print values

quiet glacier
#

i mean if the list of tags isnt printing the values def wont

#

yea no luck lol

#

which again doesn't really make sense at all

#

yea

#

uh

#

im slow lmaooo

#

edditing wrong autocomplete

wooden vale
quiet glacier