woomy-v2/bot/event_modules/eventHandler.js

67 lines
2.7 KiB
JavaScript
Raw Normal View History

/* eslint-disable indent */
class EventHandler {
2022-12-12 01:25:48 +00:00
constructor (client) {
this.client = client;
}
handle (wsEvent, param_1, param_2) {
switch (wsEvent) {
case 'ready': {
const readyModules = this.client.eventModules.filter(module => module.wsEvent === 'ready');
readyModules.forEach(module => module.run(this.client));
break;
}
case 'error': {
const errorModules = this.client.eventModules.filter(module => module.wsEvent === 'error');
2022-12-11 02:39:56 +00:00
errorModules.forEach(module => module.run(this.client, param_1));
break;
}
case 'messageCreate': {
const mCreateModules = this.client.eventModules.filter(module => module.wsEvent === 'messageCreate');
2022-12-11 02:39:56 +00:00
mCreateModules.forEach(module => module.run(this.client, param_1));
break;
}
case 'interactionCreate': {
const iCreateModules = this.client.eventModules.filter(module => module.wsEvent === 'interactionCreate');
iCreateModules.forEach(module => module.run(this.client, param_1));
break;
}
case 'guildCreate': {
const gCreateModules = this.client.eventModules.filter(module => module.wsEvent === 'guildCreate');
2022-12-11 02:39:56 +00:00
gCreateModules.forEach(module => module.run(this.client, param_1));
break;
}
case 'guildDelete': {
const gDeleteModules = this.client.eventModules.filter(module => module.wsEvent === 'guildDelete');
2022-12-11 02:39:56 +00:00
gDeleteModules.forEach(module => module.run(this.client, param_1));
break;
}
case 'guildMemberAdd': {
const gMemberAddModules = this.client.eventModules.filter(module => module.wsEvent === 'guildMemberAdd');
2022-12-11 02:39:56 +00:00
gMemberAddModules.forEach(module => module.run(this.client, param_1, param_2));
break;
}
case 'guildMemberRemove': {
const gMemberRemoveModules = this.client.eventModules.filter(module => module.wsEvent === 'guildMemberRemove');
2022-12-11 02:39:56 +00:00
gMemberRemoveModules.forEach(module => module.run(this.client, param_1, param_2));
break;
}
case 'voiceStateUpdate': {
const vStateUpdateModules = this.client.eventModules.filter(module => module.wsEvent === 'voiceStateUpdate');
2022-12-11 02:39:56 +00:00
vStateUpdateModules.forEach(module => module.run(this.client, param_1, param_2));
break;
}
}
}
}
module.exports = EventHandler;