diff --git a/src/client/components/Registry.ts b/src/client/components/Registry.ts index c771217..a483cde 100644 --- a/src/client/components/Registry.ts +++ b/src/client/components/Registry.ts @@ -60,10 +60,9 @@ class Registry /** * Assigns the component module and makes it available for the client * - * @param {Component} component Component to load - * @param {string} directory The directory in which the component resides - * @param {boolean} [silent=false] Whether to emit a component update event - * @return {Component} + * @param component Component to load + * @param directory The directory in which the component resides + * @param [silent=false] Whether to emit a component update event * @memberof Registry */ async loadComponent (component: T, directory?: string, silent = false): Promise @@ -80,9 +79,11 @@ class Registry { // Sets modules or "groups" for each component, specified by their properties. let module = this.#components.get(`module:${component.moduleName}`) as Module; if (!module) + { module = await this.loadComponent(new Module(this.#client, { name: component.moduleName })); - - this.#components.set(module.resolveable, module); + this.#components.set(module.resolveable, module); + } + component.module = module; module.components.set(component.resolveable, component); } diff --git a/src/client/components/commands/administration/Permissions.ts b/src/client/components/commands/administration/Permissions.ts index 32a6537..88e6925 100644 --- a/src/client/components/commands/administration/Permissions.ts +++ b/src/client/components/commands/administration/Permissions.ts @@ -9,8 +9,13 @@ import InvokerWrapper from '../../wrappers/InvokerWrapper.js'; import Emojis from '../../../../constants/Emojis.js'; import { PermissionSet } from '../../../../../@types/Guild.js'; -const filterInexact = (search: string) => (comp: Component) => comp.id.toLowerCase().includes(search) - || comp.resolveable.toLowerCase().includes(search); +const filterInexact = (search: string) => (comp: Component) => +{ + const id = comp.id.toLowerCase().includes(search); + const res = comp.resolveable.toLowerCase().includes(search); + // console.log(search, comp.id, id, comp.resolveable, res); + return id || res; +}; class PermissionsCommand extends SlashCommand { @@ -116,7 +121,6 @@ class PermissionsCommand extends SlashCommand } ] }); - } async execute (invoker: InvokerWrapper, { role, channel, member, permission }: CommandParams) @@ -148,23 +152,25 @@ class PermissionsCommand extends SlashCommand { for (const perm of permission.asString.split(' ')) { - const result = grantables.filter(filterInexact(perm)).first(); - if (!result) + const result = grantables.filter(filterInexact(perm.toLowerCase())).first(); + if (!result) continue; - if (result.type === 'module') + if (result.type === 'module') { const module = result as Module; for (const component of module.components.values()) + { if (component.type === 'command') { - if (component.module.id === 'administration') + if (component.module.id === 'administration') adminWarning = true; parsed.push(component.resolveable); } + } } - else + else { - if (result.module.id === 'administration') + if (result.module.id === 'administration') adminWarning = true; parsed.push(result.resolveable); } diff --git a/src/client/interfaces/Module.ts b/src/client/interfaces/Module.ts index bda1918..5d1bc4f 100644 --- a/src/client/interfaces/Module.ts +++ b/src/client/interfaces/Module.ts @@ -12,7 +12,6 @@ import { ModuleOptions } from '../../../@types/Client.js'; class Module extends Component { - #name: string; #components: Collection; @@ -31,14 +30,14 @@ class Module extends Component } - get name () + get name () { return this.#name; } - get components () + get components () { - return this.#components.clone(); + return this.#components; } }