Skip to content

Commit

Permalink
fix(mdn): truncate autocomplete name
Browse files Browse the repository at this point in the history
  • Loading branch information
almostSouji committed Dec 17, 2024
1 parent 354af81 commit 60d86ca
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/functions/autocomplete/mdnAutoComplete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,20 @@ import { InteractionResponseType } from 'discord-api-types/v10';
import type { Response } from 'polka';
import type { MdnCommand } from '../../interactions/mdn.js';
import type { MDNIndexEntry } from '../../types/mdn.js';
import { AUTOCOMPLETE_MAX_ITEMS } from '../../util/constants.js';
import { AUTOCOMPLETE_MAX_ITEMS, AUTOCOMPLETE_MAX_NAME_LENGTH } from '../../util/constants.js';
import { transformInteraction } from '../../util/interactionOptions.js';
import { truncate } from '../../util/truncate.js';

type MDNCandidate = {
entry: MDNIndexEntry;
matches: string[];
};

function autoCompleteMap(elements: MDNCandidate[]) {
return elements.map((element) => ({ name: element.entry.title, value: element.entry.url }));
return elements.map((element) => ({
name: truncate(element.entry.title, AUTOCOMPLETE_MAX_NAME_LENGTH, ''),
value: element.entry.url,
}));
}

export function mdnAutoComplete(
Expand Down

0 comments on commit 60d86ca

Please sign in to comment.