mirror of
https://github.com/xHyroM/bun-discord-bot.git
synced 2024-11-22 14:41:05 +01:00
feat: allow more tags in findTags
This commit is contained in:
parent
f69c0b97f1
commit
119d8dee7b
1 changed files with 14 additions and 11 deletions
|
@ -13,9 +13,14 @@ for (const [key, value] of Object.entries(tags)) {
|
||||||
tagCache.set(key, value as unknown as Tag);
|
tagCache.set(key, value as unknown as Tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getTag = (name: string) => {
|
export const getTag = (name: string, more?: boolean) => {
|
||||||
const tag = tagCache.get(name) || tagCache.find(tag => tag.keywords.some(k => k.includes(name)));
|
if (more) {
|
||||||
return tag;
|
const tags = [...tagCache.filter(tag => tag.keywords.some(k => k.includes(name))).values()];
|
||||||
|
return tags;
|
||||||
|
} else {
|
||||||
|
const tag = tagCache.get(name) || tagCache.find(tag => tag.keywords.some(k => k.includes(name)));
|
||||||
|
return tag;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const findTags = (name: string) => {
|
export const findTags = (name: string) => {
|
||||||
|
@ -27,14 +32,12 @@ export const findTags = (name: string) => {
|
||||||
})).slice(0, 25)
|
})).slice(0, 25)
|
||||||
];
|
];
|
||||||
else {
|
else {
|
||||||
const tag = getTag(name);
|
const tags: Tag[] = getTag(name, true) as Tag[];
|
||||||
if (tag)
|
if (tags.length > 0)
|
||||||
return [
|
return tags.map(tag => new Object({
|
||||||
{
|
name: tag.keywords[0],
|
||||||
name: tag.keywords[0],
|
value: tag.keywords[0]
|
||||||
value: tag.keywords[0],
|
}));
|
||||||
}
|
|
||||||
];
|
|
||||||
else return findTags(null);
|
else return findTags(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue