From 2022ec483356f824b1999c0c77db87a3e993a2ff Mon Sep 17 00:00:00 2001 From: almostSouji Date: Sat, 27 Jul 2024 12:21:39 +0200 Subject: [PATCH] fix(docs): use dotted name for version cache lookup * caused a fallback to main for every query since discord.js is not discord-js --- src/functions/autocomplete/docsAutoComplete.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/functions/autocomplete/docsAutoComplete.ts b/src/functions/autocomplete/docsAutoComplete.ts index 9fe1897..40f361a 100644 --- a/src/functions/autocomplete/docsAutoComplete.ts +++ b/src/functions/autocomplete/docsAutoComplete.ts @@ -36,6 +36,10 @@ export function parseDocsPath(path: string) { }; } +function convertToDottedName(dashed: string) { + return dashed.replaceAll('-', '.'); +} + export async function djsAutoComplete( res: Response, options: APIApplicationCommandInteractionDataOption[], @@ -56,7 +60,7 @@ export async function djsAutoComplete( throw new Error('expected query option, none received'); } - const version = versionOptionData?.value ?? versions.versions.get(option.name)?.at(1) ?? 'main'; + const version = versionOptionData?.value ?? versions.versions.get(convertToDottedName(option.name))?.at(1) ?? 'main'; const docsResult = await queryDocs(queryOptionData.value, option.name, version); const choices = []; @@ -103,7 +107,7 @@ export function resolveOptionsToDocsAutoComplete( return undefined; } - const versions = allversions.versions.get(source.replaceAll('-', '.')); + const versions = allversions.versions.get(convertToDottedName(source)); let query = 'Client'; let version = versions?.at(1) ?? 'main';