Skip to content

Commit 60d86ca

Browse files
committed
fix(mdn): truncate autocomplete name
1 parent 354af81 commit 60d86ca

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/functions/autocomplete/mdnAutoComplete.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,20 @@ import { InteractionResponseType } from 'discord-api-types/v10';
33
import type { Response } from 'polka';
44
import type { MdnCommand } from '../../interactions/mdn.js';
55
import type { MDNIndexEntry } from '../../types/mdn.js';
6-
import { AUTOCOMPLETE_MAX_ITEMS } from '../../util/constants.js';
6+
import { AUTOCOMPLETE_MAX_ITEMS, AUTOCOMPLETE_MAX_NAME_LENGTH } from '../../util/constants.js';
77
import { transformInteraction } from '../../util/interactionOptions.js';
8+
import { truncate } from '../../util/truncate.js';
89

910
type MDNCandidate = {
1011
entry: MDNIndexEntry;
1112
matches: string[];
1213
};
1314

1415
function autoCompleteMap(elements: MDNCandidate[]) {
15-
return elements.map((element) => ({ name: element.entry.title, value: element.entry.url }));
16+
return elements.map((element) => ({
17+
name: truncate(element.entry.title, AUTOCOMPLETE_MAX_NAME_LENGTH, ''),
18+
value: element.entry.url,
19+
}));
1620
}
1721

1822
export function mdnAutoComplete(

0 commit comments

Comments
 (0)