beanc16 / roll-of-darkness-bot

A discord bot for rolling dice in the New World of Darkness, Pokemon Tabletop United, and Curseborne tabletop systems
1 stars 0 forks source link

Make the `pokemon_page_name` dropdown in `/ptu train` autocomplete #29

Open beanc16 opened 1 day ago

beanc16 commented 1 day ago

Currently, pokemon_page_name in /ptu train makes you type the name of a pokemon's sheet in order to train the pokemon. However, it assumes you always type it correctly, and some people's sheet names are long, making them inconvenient to type. This could be dramatically improved by making it autocomplete and providing options for users to choose from as they type.

The expected workflow would be:

  1. Retrieve all in-use pokemon pages from all character sheets
  2. Allow the pokemon page name or pokemon's nickname (if it exists) to be used
  3. Display that as its seached

Optionally, consider pre-fetching this on bot startup for early caching. Though, this isn't required since this workflow isn't used as frequently as other between sessions like /ptu lookup. However, if it proves too long (3 seconds) to initialize the data on first use of this command without this pre-caching, then this becomes a requirement rather than optional.

This will require adding a new endpoint to the google-sheets-microservice for retrieving all page names of a given spreadsheet, and then filtering those down in this service or with payload/query parameters on the new endpoint before then using valid pokemon sheets that meet the autocomplete requirements as potential responses.

beanc16 commented 6 hours ago

I added the new necessary endpoint to the google-sheets-microservice and added a function to it to the microservice abstraction. Our data contract will end up looking something like this when calling getPageTitles on the abstraction in order to exclude all data except for the pokemon on a given spreadsheet:

{
    "spreadsheetId": "someSpreadsheetId",
    "filters": [
        {
            "type": "case_insensitive_excludes",
            "values": [
                "Trainer",
                "Features",
                "Edges",
                "Extras",
                "Inventory",
                "Combat",
                " Data",
                " Template",
                " Skills",
                "Pokédex",
                "Pokedex",
                "Calculations",
                "Poke Edges",
                "Poké Edges"
            ]
        }
    ]
}

Though, we'll need to get this data for multiple spreadsheets at a time, so I'll likely go back and make a bulk version of this endpoint as well.