2017-07-27 09:50:44 +03:00
|
|
|
//node imports
|
|
|
|
const FileSystem = require("fs");
|
|
|
|
|
|
|
|
//external lib imports
|
|
|
|
const JSONFile = require("jsonfile");
|
|
|
|
|
|
|
|
//app component imports
|
|
|
|
const GuildData = require("./models/guild-data.js");
|
|
|
|
|
|
|
|
const SAVE_FILE = "./guilds.json";
|
|
|
|
|
2017-07-27 00:29:05 +03:00
|
|
|
//acts as on ready function
|
|
|
|
module.exports = (client) => {
|
2017-07-27 09:50:44 +03:00
|
|
|
const guildsData = FileSystem.existsSync(SAVE_FILE) ? parseJSON(JSONFile.readFileSync(SAVE_FILE)) : {}; //pull saved data from file
|
|
|
|
|
2017-07-27 00:29:05 +03:00
|
|
|
//set up an interval to check all the feeds
|
|
|
|
|
|
|
|
//set up an on message handler to detect when links are posted
|
2017-07-27 09:50:44 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
function parseJSON(json) {
|
|
|
|
const guildIDs = Object.keys(json);
|
|
|
|
guildIDs.forEach(guildID => { guildIDs[guildID] = new GuildData(guildIDs[guildID]); });
|
|
|
|
}
|