remove init function (async not needed)
This commit is contained in:
parent
2b05540e24
commit
e34d8cac57
1 changed files with 42 additions and 31 deletions
37
bot/index.js
37
bot/index.js
|
@ -17,18 +17,23 @@ class WoomyClient extends Eris.Client {
|
||||||
constructor (token, options) {
|
constructor (token, options) {
|
||||||
super(token, options);
|
super(token, options);
|
||||||
|
|
||||||
|
// Important information Woomy needs to access
|
||||||
this.config = config;
|
this.config = config;
|
||||||
this.path = __dirname;
|
this.path = __dirname;
|
||||||
this.version = version;
|
this.version = version;
|
||||||
|
|
||||||
|
// Load up our command/event modules
|
||||||
this.commandFiles = read('./commands').filter(file => file.endsWith('.js'));
|
this.commandFiles = read('./commands').filter(file => file.endsWith('.js'));
|
||||||
this.eventFiles = read('./event_modules').filter(file => file.endsWith('.js'));
|
this.eventFiles = read('./event_modules').filter(file => file.endsWith('.js'));
|
||||||
|
|
||||||
|
// Essential modules
|
||||||
this.logger = Logger;
|
this.logger = Logger;
|
||||||
this.db = new Database(this);
|
this.db = new Database(this);
|
||||||
this.helpers = new Helpers(this);
|
this.helpers = new Helpers(this);
|
||||||
this.eventHandler = new EventHandler(this);
|
this.eventHandler = new EventHandler(this);
|
||||||
// this.messageHandler = new messageHandler(this);
|
// this.messageHandler = new messageHandler(this);
|
||||||
|
|
||||||
|
// Collections to store our successfully loaded commands and events in.
|
||||||
this.commands = new Eris.Collection();
|
this.commands = new Eris.Collection();
|
||||||
this.aliases = new Eris.Collection();
|
this.aliases = new Eris.Collection();
|
||||||
this.cooldowns = new Eris.Collection();
|
this.cooldowns = new Eris.Collection();
|
||||||
|
@ -126,8 +131,7 @@ class WoomyClient extends Eris.Client {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function init () {
|
const client = new WoomyClient(config.token, {
|
||||||
const client = new WoomyClient(config.token, {
|
|
||||||
maxShards: 'auto',
|
maxShards: 'auto',
|
||||||
defaultImageFormat: 'png',
|
defaultImageFormat: 'png',
|
||||||
defaultImageSize: 2048,
|
defaultImageSize: 2048,
|
||||||
|
@ -141,26 +145,33 @@ async function init () {
|
||||||
'directMessages',
|
'directMessages',
|
||||||
'directMessageReactions'
|
'directMessageReactions'
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
require('./util/prototypes');
|
require('./util/prototypes');
|
||||||
|
|
||||||
client.loadCommands();
|
client.loadCommands();
|
||||||
client.loadEventModules();
|
client.loadEventModules();
|
||||||
client.createEventListeners();
|
client.createEventListeners();
|
||||||
|
|
||||||
if (client.config.devmode === true) {
|
if (client.config.devmode === true) {
|
||||||
try {
|
try {
|
||||||
// sentry.init({ dsn: client.config.keys.sentry });
|
// sentry.init({ dsn: client.config.keys.sentry });
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
client.logger.error('SENTRY_INIT_ERROR', `Sentry failed to initialize: ${err}`);
|
client.logger.error('SENTRY_INIT_ERROR', `Sentry failed to initialize: ${err}`);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
client.logger.warning('DEVELOPMENT_MODE', 'Running in development mode, some features have been disabled.');
|
client.logger.warning('DEVELOPMENT_MODE', 'Running in development mode, some features have been disabled.');
|
||||||
}
|
|
||||||
|
|
||||||
client.connect();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
init ();
|
client.connect();
|
||||||
|
|
||||||
|
// Process exception/promise rejection listeners
|
||||||
|
|
||||||
|
process.on('uncaughtException', (error) => {
|
||||||
|
const errorMsg = error.stack.replace(new RegExp(`${client.path}/`, 'g'), './');
|
||||||
|
client.logger.error('UNCAUGHT_EXCEPTION_ERROR', errorMsg);
|
||||||
|
});
|
||||||
|
|
||||||
|
process.on('unhandledRejection', err => {
|
||||||
|
client.logger.error('UNHANDLED_PROMISE_ERROR', err);
|
||||||
|
});
|
Loading…
Reference in a new issue