Skip to content

Commit

Permalink
fix(docs): use dotted name for version cache lookup
Browse files Browse the repository at this point in the history
* caused a fallback to main for every query since discord.js is not discord-js
  • Loading branch information
almostSouji committed Jul 27, 2024
1 parent 14cd40e commit 2022ec4
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/functions/autocomplete/docsAutoComplete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ export function parseDocsPath(path: string) {
};
}

function convertToDottedName(dashed: string) {
return dashed.replaceAll('-', '.');
}

export async function djsAutoComplete(
res: Response,
options: APIApplicationCommandInteractionDataOption[],
Expand All @@ -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 = [];

Expand Down Expand Up @@ -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';
Expand Down

0 comments on commit 2022ec4

Please sign in to comment.