Add auto disconnect

This commit is contained in:
Max Isom 2020-03-16 20:14:15 -05:00
parent 32cb3ca4ae
commit ac21b5657b
5 changed files with 45 additions and 19 deletions

View file

@ -2,9 +2,10 @@ import {Client, Message, Collection} from 'discord.js';
import {inject, injectable} from 'inversify';
import {TYPES} from './types';
import {Settings, Shortcut} from './models';
import handleGuildCreate from './events/guild-create';
import container from './inversify.config';
import Command from './commands';
import handleGuildCreate from './events/guild-create';
import handleVoiceStateUpdate from './events/voice-state-update';
@injectable()
export default class {
@ -87,12 +88,11 @@ export default class {
console.log(`Ready! Invite the bot with https://discordapp.com/oauth2/authorize?client_id=${this.clientId}&scope=bot`);
});
this.client.on('error', error => {
console.error(error);
});
this.client.on('error', console.error);
// Register event handlers
this.client.on('guildCreate', handleGuildCreate);
this.client.on('voiceStateUpdate', handleVoiceStateUpdate);
return this.client.login(this.token);
}