This repository has been archived by the owner on Dec 19, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Matthew Ray
committed
Oct 21, 2018
1 parent
dcac085
commit c4f5f62
Showing
1 changed file
with
33 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
//}; | ||
}); | ||
}; |