2022-12-09 12:41:29 +00:00
|
|
|
/* eslint-disable indent */
|
|
|
|
|
|
|
|
class EventHandler {
|
|
|
|
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));
|
2022-12-09 12:41:29 +00:00
|
|
|
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));
|
2022-12-09 12:41:29 +00:00
|
|
|
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));
|
2022-12-09 12:41:29 +00:00
|
|
|
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));
|
2022-12-09 12:41:29 +00:00
|
|
|
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));
|
2022-12-09 12:41:29 +00:00
|
|
|
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));
|
2022-12-09 12:41:29 +00:00
|
|
|
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));
|
2022-12-09 12:41:29 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = EventHandler;
|