Simplify events

This commit is contained in:
Christer Warén
2023-06-06 03:41:04 +03:00
parent 348ac90cba
commit 87cf4b62c8
10 changed files with 232 additions and 257 deletions

View File

@ -1,3 +1,4 @@
import RadioClient from "../Client"
import interactionCreate from "./events/interactionCreate"
import messageDelete from "./events/messageDelete"
import ready from "./events/ready"
@ -7,6 +8,46 @@ import uncaughtException from "./events/uncaughtException"
import voiceStateUpdate from "./events/voiceStateUpdate"
import warning from "./events/warning"
export const events = {
interactionCreate, messageDelete, ready, SIGINT, SIGTERM, uncaughtException, voiceStateUpdate, warning
export default function events(client: RadioClient) {
client.on("ready", () => {
ready(client);
});
client.on("messageDelete", msg => {
messageDelete(client, msg);
});
client.on("interactionCreate", interaction => {
interactionCreate(client, interaction);
});
client.on("voiceStateUpdate", (oldState, newState) => {
voiceStateUpdate(client, oldState, newState);
});
client.on("error", error => {
client.funcs.logger("Discord Client", "Error");
console.error(error);
console.log('');
});
process.on('SIGINT', () => {
SIGINT(client);
});
process.on('SIGTERM', () => {
SIGTERM(client);
});
process.on('uncaughtException', (error) => {
uncaughtException(client, error);
});
process.on('exit', () => {
client.funcs.logger("Bot", "Stopping");
});
process.on('warning', (error) => {
warning(client, error);
});
}