slash-create/docs-bot

`/search` fails to fetch class and typedef entity keys

Closed this issue · 3 comments

The typeMap is shown to have these contained within all, yet TypeError occurs when it fails to find a class or typedef.

An additional change to /search requires the consideration of an entity if it's a typedef to treat it similar to a class, but also as it's own type (/docs class class: * -> /docs typedef typedef: *).

const [, first, second] = query.match(/(\w+)[#~$](\w+)/);
const subtype = TypeNavigator.typeMap.all[query];

For now, an onError catch would work for the command itself - but it would be troubling if it persists after fix is implemented.

image

The class entity exists, but it cannot be retrieved.

Code to achieve the above for /search:

class SearchCommand extends SlashCommand {
  // ...
  onError(err: Error, ctx: CommandContext) {
    ctx.send(
      [
        'An error has occured, I could not find what you were looking for.',
        `> ${err.message}`,
        `> \`${ctx.options.query}\` -> ? ${ctx.options.query in TypeNavigator.typeMap.all}`
      ].join('\n'),
      {
        ephemeral: true
      }
    );
  }
  // ...
}

Turns out, I dumb dumb - query.match was the problem because attempting to extract a null entry for class or typedef is fatal... whoops. As a side note, it turns out command mentions cannot be selected from ephemeral responses (but I may keep it in anyway).
image