zumito-framework 1.1.21 → 1.1.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/types/Module.d.ts +1 -0
- package/dist/types/Module.js +12 -2
- package/package.json +1 -1
package/dist/types/Module.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export declare abstract class Module {
|
|
|
12
12
|
getCommands(): Map<string, Command>;
|
|
13
13
|
registerEvents(): void;
|
|
14
14
|
registerDiscordEvent(frameworkEvent: FrameworkEvent): void;
|
|
15
|
+
parseEventArgs(args: any[]): any;
|
|
15
16
|
getEvents(): Map<string, FrameworkEvent>;
|
|
16
17
|
registerTranslations(): void;
|
|
17
18
|
getTranslations(): Map<string, string>;
|
package/dist/types/Module.js
CHANGED
|
@@ -56,12 +56,22 @@ class Module {
|
|
|
56
56
|
const once = frameworkEvent.once; // A simple variable which returns if the event should run once
|
|
57
57
|
// Try catch block to throw an error if the code in try{} doesn't work
|
|
58
58
|
try {
|
|
59
|
-
emitter[once ? 'once' : 'on'](eventName, (...args) => frameworkEvent.execute(
|
|
59
|
+
emitter[once ? 'once' : 'on'](eventName, (...args) => frameworkEvent.execute(this.parseEventArgs(args))); // Run the event using the above defined emitter (client)
|
|
60
60
|
}
|
|
61
61
|
catch (error) {
|
|
62
62
|
console.error(error.stack); // If there is an error, console log the error stack message
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
|
+
parseEventArgs(args) {
|
|
66
|
+
let finalArgs = {
|
|
67
|
+
framework: this.framework,
|
|
68
|
+
client: this.framework.client,
|
|
69
|
+
};
|
|
70
|
+
args.forEach(arg => {
|
|
71
|
+
finalArgs[arg.constructor.name.toLowerCase()] = arg;
|
|
72
|
+
});
|
|
73
|
+
return finalArgs;
|
|
74
|
+
}
|
|
65
75
|
getEvents() {
|
|
66
76
|
return this.events;
|
|
67
77
|
}
|
|
@@ -85,7 +95,7 @@ class Module {
|
|
|
85
95
|
}
|
|
86
96
|
}
|
|
87
97
|
else {
|
|
88
|
-
this.translations.set(path, json);
|
|
98
|
+
this.translations.set(path.slice(0, -1), json);
|
|
89
99
|
}
|
|
90
100
|
}
|
|
91
101
|
}
|