Update data deletion to require a reset command instead of guildDelete
guildDelete apparently gets called whenever Discord has an outage - we don't want to delete server data whenever there is a temporary outage!
This commit is contained in:
parent
672c07f5b0
commit
f1f81a9ba4
|
@ -32,7 +32,6 @@ module.exports = class Client extends Discord.Client {
|
||||||
this.on("message", this._onMessage);
|
this.on("message", this._onMessage);
|
||||||
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);
|
|
||||||
process.on("uncaughtException", err => this._onUnhandledException(this, err));
|
process.on("uncaughtException", err => this._onUnhandledException(this, err));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,12 +57,6 @@ module.exports = class Client extends Discord.Client {
|
||||||
CoreUtil.dateLog(`Added to guild ${guild.name}`);
|
CoreUtil.dateLog(`Added to guild ${guild.name}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
_onGuildDelete(guild) {
|
|
||||||
this.guildDataModel.findOneAndDelete({ guildID: guild.id });
|
|
||||||
|
|
||||||
CoreUtil.dateLog(`Removed from guild ${guild.name}, removing data for this guild`);
|
|
||||||
}
|
|
||||||
|
|
||||||
_onUnhandledException(client, err) {
|
_onUnhandledException(client, err) {
|
||||||
CoreUtil.dateError("Unhandled exception!\n", err);
|
CoreUtil.dateError("Unhandled exception!\n", err);
|
||||||
CoreUtil.dateLog("Destroying existing client...");
|
CoreUtil.dateLog("Destroying existing client...");
|
||||||
|
|
18
discord-bot-core/core-commands/reset.js
Normal file
18
discord-bot-core/core-commands/reset.js
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
const Command = require("../command.js");
|
||||||
|
|
||||||
|
module.exports = new Command({
|
||||||
|
name: "reset",
|
||||||
|
description: "Reset all data for this Discord server. WARNING: YOU WILL LOSE ALL YOUR SETTINGS!",
|
||||||
|
syntax: "reset",
|
||||||
|
admin: false,
|
||||||
|
invoke
|
||||||
|
});
|
||||||
|
|
||||||
|
function invoke({ guildData }) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
guildData
|
||||||
|
.delete()
|
||||||
|
.then(() => resolve("Data for this server successfully deleted"))
|
||||||
|
.catch(() => reject("Error deleting data for this server"));
|
||||||
|
});
|
||||||
|
}
|
Loading…
Reference in a new issue