Revert removal of restart on unhandled exception
Turns out maybe it is actually somewhat useful after all
This commit is contained in:
parent
b6ac3b2518
commit
b1ac656bee
|
@ -32,6 +32,7 @@ module.exports = class Client extends Discord.Client {
|
|||
this.on("debug", this._onDebug);
|
||||
this.on("guildCreate", this._onGuildCreate);
|
||||
this.on("guildDelete", this._onGuildDelete);
|
||||
process.on("uncaughtException", err => this._onUnhandledException(this, err));
|
||||
}
|
||||
|
||||
bootstrap() {
|
||||
|
@ -70,6 +71,15 @@ module.exports = class Client extends Discord.Client {
|
|||
|
||||
CoreUtil.dateLog(`Removed from guild ${guild.name}, removing data for this guild`);
|
||||
}
|
||||
|
||||
_onUnhandledException(client, err) {
|
||||
CoreUtil.dateError("Unhandled exception!\n", err);
|
||||
CoreUtil.dateLog("Destroying existing client...");
|
||||
client.destroy().then(() => {
|
||||
CoreUtil.dateLog("Client destroyed, recreating...");
|
||||
setTimeout(() => client.login(client._token), InternalConfig.reconnectTimeout);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
function compactCollections() {
|
||||
|
|
Loading…
Reference in New Issue