Add removal of data on startup if the bot has left the guild
This commit is contained in:
parent
446292b057
commit
c151201384
|
@ -46,6 +46,10 @@ module.exports = class Client extends Discord.Client {
|
||||||
onReady() {
|
onReady() {
|
||||||
this.user.setGame(InternalConfig.website.replace(/^https?:\/\//, ""));
|
this.user.setGame(InternalConfig.website.replace(/^https?:\/\//, ""));
|
||||||
CoreUtil.dateLog(`Registered bot ${this.user.username}`);
|
CoreUtil.dateLog(`Registered bot ${this.user.username}`);
|
||||||
|
|
||||||
|
for (let guildID of Object.keys(this.guildsData))
|
||||||
|
if (!this.guilds.get(guildID))
|
||||||
|
delete this.guildsData[guildID];
|
||||||
}
|
}
|
||||||
|
|
||||||
onMessage(message) {
|
onMessage(message) {
|
||||||
|
@ -93,7 +97,9 @@ module.exports = class Client extends Discord.Client {
|
||||||
*/
|
*/
|
||||||
fromJSON(json) {
|
fromJSON(json) {
|
||||||
const guildsData = Object.keys(json);
|
const guildsData = Object.keys(json);
|
||||||
guildsData.forEach(guildID => { json[guildID] = new this.guildDataModel(json[guildID]); });
|
guildsData.forEach(guildID => {
|
||||||
|
json[guildID] = new this.guildDataModel(json[guildID]);
|
||||||
|
});
|
||||||
return json;
|
return json;
|
||||||
}
|
}
|
||||||
};
|
};
|
Loading…
Reference in a new issue