*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:
parent
677a55d935
commit
4b5e738b00
10
src/index.ts
10
src/index.ts
|
@ -117,10 +117,16 @@ export const factory = function <T extends Client = Client>(
|
|||
return function (...args: any): T {
|
||||
return new Proxy<T>(new type(...args), {
|
||||
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);
|
||||
|
||||
return target[property as keyof T];
|
||||
return (target[property as keyof T] as Function)(...args);
|
||||
};
|
||||
},
|
||||
});
|
||||
|
|
Reference in New Issue