Revert removal of restart on unhandled exception
Turns out maybe it is actually somewhat useful after all
This commit is contained in:
parent
9c0602bbb6
commit
65d2745cdc
|
@ -32,6 +32,7 @@ module.exports = class Client extends Discord.Client {
|
||||||
this.on("debug", this._onDebug);
|
this.on("debug", this._onDebug);
|
||||||
this.on("guildCreate", this._onGuildCreate);
|
this.on("guildCreate", this._onGuildCreate);
|
||||||
this.on("guildDelete", this._onGuildDelete);
|
this.on("guildDelete", this._onGuildDelete);
|
||||||
|
process.on("uncaughtException", err => this._onUnhandledException(this, err));
|
||||||
}
|
}
|
||||||
|
|
||||||
bootstrap() {
|
bootstrap() {
|
||||||
|
@ -70,6 +71,15 @@ module.exports = class Client extends Discord.Client {
|
||||||
|
|
||||||
CoreUtil.dateLog(`Removed from guild ${guild.name}, removing data for this guild`);
|
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() {
|
function compactCollections() {
|
||||||
|
|
Loading…
Reference in a new issue