Skip to content
This repository has been archived by the owner on Dec 19, 2018. It is now read-only.

Commit

Permalink
Add 51 guildDelete logs
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Ray committed Oct 21, 2018
1 parent dcac085 commit c4f5f62
Showing 1 changed file with 33 additions and 18 deletions.
51 changes: 33 additions & 18 deletions events/guildDelete.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,44 @@
// This event executes when a new guild (server) is left.
const fs = require('fs')
const fs = require('fs');
module.exports = (client, guild) => {
client.logger.cmd(`[GUILD LEAVE] ${guild.name} (${guild.id}) removed the bot.`);
fs.readFile("./allowedGuildDB.json", "utf8", async (err, data) => { // readFile method basically allows us to read the data in that file
fs.readFile('./allowedGuildDB.json', 'utf8', async (err, data) => { // readFile method basically allows us to read the data in that file
if (err !== null) { // Just an error checker
return console.log(err);
return console.log(err);
}
else {
const guildID = args[0];
}
const requiredData = JSON.parse(data);
requiredData.allowedGuildIDs.shift(guildID);
// And now we write the final data again
const json = JSON.stringify(requiredData);
fs.writeFile("./allowedGuildDB.json", json, "utf8", (err) => {
const guildID = guild.id;
//if (typeof (args[0]) !== 'number') return message.channel.send('TypeError: Cannot read property \'guildID\' of undefined');

const requiredData = JSON.parse(data);
const index = requiredData.allowedGuildIDs.indexOf(guildID);
if (index !== -1) {
requiredData.allowedGuildIDs.splice(index, 1);
// And now we write the final data again
const json = JSON.stringify(requiredData);
fs.writeFile('./allowedGuildDB.json', json, 'utf8', (err) => {
if (err !== null) {
console.log(err);
}
});
}
/* const requiredData = JSON.parse(data);
requiredData.allowedGuildIDs.shift(guildID);
// And now we write the final data again
const json = JSON.stringify(requiredData);
fs.writeFile('./allowedGuildDB.json', json, 'utf8', (err) => {
if (err !== null) {
console.log(err);
console.log(err);
}
});
})
});*/
}

// If the settings Enmap contains any guild overrides, remove them.
// No use keeping stale data!
if (client.settings.has(guild.id)) {
client.settings.delete(guild.id);
}
// If the settings Enmap contains any guild overrides, remove them.
// No use keeping stale data!
if (client.settings.has(guild.id)) {
client.settings.delete(guild.id);
}
//};
});
};

0 comments on commit c4f5f62

Please sign in to comment.