diff --git a/src/commands/search.ts b/src/commands/search.ts index 69fc5f0..e074c6b 100644 --- a/src/commands/search.ts +++ b/src/commands/search.ts @@ -37,8 +37,8 @@ export async function execute(interaction: ChatInputCommandInteraction) { const response = results.length ? results .map( - ({ word, meaning, extra, type }) => - `${word} (${type}): ${meaning} ${extra?.join(' ') ?? ''}` + ({ word, meaning, impl, type }) => + `${word} (${type}): ${meaning}${impl ? ` – ${impl}` : ''}` ) .join('\n') : 'No results found.'; diff --git a/src/lib/kumilinwa/search.ts b/src/lib/kumilinwa/search.ts index 305fe2b..c505f8c 100644 --- a/src/lib/kumilinwa/search.ts +++ b/src/lib/kumilinwa/search.ts @@ -6,15 +6,19 @@ export async function searchLangSpec( matching?: MatchType ): Promise { const matchWord = matching === 'word' || !matching, - matchMeaning = matching === 'meaning' || !matching; + matchMeaning = matching === 'meaning' || !matching, + matchImpl = matching === 'impl' || !matching, + matchObscurism = matching === 'obscurism' || !matching; const results: FullEntry[] = []; for (const entry of await CompleteLangSpec()) if ( (matchWord && entry.word.includes(query)) || - (matchMeaning && entry.meaning.includes(query)) + (matchMeaning && (entry.meaning ?? entry.impl!).includes(query)) || + (matchImpl && entry.impl?.includes(query)) || + (matchObscurism && entry.obscurism?.includes(query)) ) results.push(entry); return results; } -export type MatchType = 'word' | 'meaning'; +export type MatchType = 'word' | 'meaning' | 'impl' | 'obscurism' | 'all'; diff --git a/src/lib/kumilinwa/types.ts b/src/lib/kumilinwa/types.ts index c12d9b3..8b304ce 100644 --- a/src/lib/kumilinwa/types.ts +++ b/src/lib/kumilinwa/types.ts @@ -1,17 +1,18 @@ +/** + * The type of the entry in each separated file (i.e. verbs.json) + */ export interface Section { - title?: string; - type: WordType; + title: string | null; headers: string[]; + type: WordType; entries: Entry[]; } -/** - * The type of the entry in each separated file (i.e. verbs.json) - */ export interface Entry { word: string; - meaning: string; - extra?: string[]; + meaning: string | null; + impl: string | null; + obscurism: string | null; } /** @@ -36,4 +37,5 @@ export type WordType = | 'preposition' | 'pronoun' | 'suffix' - | 'verb'; + | 'verb' + | 'article';