components by tag
This commit is contained in:
parent
47ab29f901
commit
13b404bffd
@ -15,12 +15,12 @@ class Resolver {
|
|||||||
* @returns
|
* @returns
|
||||||
* @memberof Resolver
|
* @memberof Resolver
|
||||||
*/
|
*/
|
||||||
components(str = '', type, exact = true) {
|
components(str = '', type = 'any', exact = true) {
|
||||||
|
|
||||||
const string = str.toLowerCase();
|
const string = str.toLowerCase();
|
||||||
|
|
||||||
const components = this.client.registry.components
|
const components = this.client.registry.components
|
||||||
.filter((c) => c.type === type)
|
.filter((c) => type === 'any' ? ['command', 'setting'].includes(c.type) : c.type === type)
|
||||||
.filter(exact ? filterExact(string) : filterInexact(string)) //eslint-disable-line no-use-before-define
|
.filter(exact ? filterExact(string) : filterInexact(string)) //eslint-disable-line no-use-before-define
|
||||||
.array();
|
.array();
|
||||||
|
|
||||||
@ -28,6 +28,19 @@ class Resolver {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
componentsByTag(str, type, exact = true) {
|
||||||
|
|
||||||
|
const key = str.toLowerCase();
|
||||||
|
|
||||||
|
const components = this.client.registry.components
|
||||||
|
.filter((c) => c.type === type)
|
||||||
|
.filter(exact ? (c) => c.tags.includes(key) : filterInexactTags(key))
|
||||||
|
.array();
|
||||||
|
|
||||||
|
return components || [];
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
timeAgo(diff, extraMin = false, extraHours = false, extraDays = false) {
|
timeAgo(diff, extraMin = false, extraHours = false, extraDays = false) {
|
||||||
|
|
||||||
diff = parseInt(diff);
|
diff = parseInt(diff);
|
||||||
@ -501,3 +514,9 @@ const filterInexact = (search) => (comp) => comp.id.toLowerCase().includes(searc
|
|||||||
comp.resolveable.toLowerCase().includes(search) ||
|
comp.resolveable.toLowerCase().includes(search) ||
|
||||||
comp.aliases && (comp.aliases.some((ali) => `${comp.type}:${ali}`.toLowerCase().includes(search)) ||
|
comp.aliases && (comp.aliases.some((ali) => `${comp.type}:${ali}`.toLowerCase().includes(search)) ||
|
||||||
comp.aliases.some((ali) => ali.toLowerCase().includes(search)));
|
comp.aliases.some((ali) => ali.toLowerCase().includes(search)));
|
||||||
|
|
||||||
|
const filterInexactTags = (search) => (comp) => comp.id.toLowerCase().includes(search.toLowerCase()) ||
|
||||||
|
comp.resolveable.toLowerCase().includes(search.toLowerCase()) ||
|
||||||
|
comp.aliases && (comp.aliases.some((ali) => `${comp.type}:${ali}`.toLowerCase().includes(search.toLowerCase())) ||
|
||||||
|
comp.aliases.some((ali) => ali.toLowerCase().includes(search.toLowerCase())) ||
|
||||||
|
comp.tags.some((tag) => tag.toLowerCase().includes(search.toLowerCase())));
|
Loading…
Reference in New Issue
Block a user