Add removal of data on startup if the bot has left the guild

This commit is contained in:
benji7425 2017-11-12 19:44:19 +00:00
parent 446292b057
commit c151201384
1 changed files with 7 additions and 1 deletions

View File

@ -46,6 +46,10 @@ module.exports = class Client extends Discord.Client {
onReady() {
this.user.setGame(InternalConfig.website.replace(/^https?:\/\//, ""));
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) {
@ -93,7 +97,9 @@ module.exports = class Client extends Discord.Client {
*/
fromJSON(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;
}
};