*If prop is not a function, just pass through. If it is a function then pass through an async call with var args

This commit is contained in:
Derrick Hammer 2023-01-31 08:04:48 -05:00
parent 677a55d935
commit 4b5e738b00
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 8 additions and 2 deletions

View File

@ -117,10 +117,16 @@ export const factory = function <T extends Client = Client>(
return function (...args: any): T { return function (...args: any): T {
return new Proxy<T>(new type(...args), { return new Proxy<T>(new type(...args), {
get(target: T, property: string) { get(target: T, property: string) {
return async (): Promise<any> => { const prop = target[property as keyof T];
if (typeof prop !== "function") {
return prop;
}
return async (...args: any[]): Promise<any> => {
await target.loadLibs(module); await target.loadLibs(module);
return target[property as keyof T]; return (target[property as keyof T] as Function)(...args);
}; };
}, },
}); });