Co-authored-by: maria-rcks <[email protected]> Co-authored-by: t3-code[bot] <269035359+t3-code[bot]@users.noreply.github.com>
17 lines
611 B
TypeScript
17 lines
611 B
TypeScript
import type { ServerProviderSkill } from "@t3tools/contracts";
|
|
|
|
export function matchesSlashSkillQuery(skill: ServerProviderSkill, query: string): boolean {
|
|
if (!skill.enabled) return false;
|
|
const normalizedQuery = query.toLowerCase();
|
|
const skillQuery =
|
|
normalizedQuery === "skill"
|
|
? ""
|
|
: normalizedQuery.startsWith("skill:")
|
|
? normalizedQuery.slice("skill:".length)
|
|
: normalizedQuery;
|
|
if (!skillQuery) return true;
|
|
return [skill.name, skill.displayName, skill.shortDescription, skill.description].some((value) =>
|
|
value?.toLowerCase().includes(skillQuery),
|
|
);
|
|
}
|