From d22c9b91dcb85b1abc9ef8951d3db004b447b6d2 Mon Sep 17 00:00:00 2001 From: benji7425 Date: Sat, 9 Sep 2017 20:25:50 +0100 Subject: [PATCH] Add onReady function in bot.js --- app/bot.js | 7 +++++++ app/index.js | 2 ++ 2 files changed, 9 insertions(+) diff --git a/app/bot.js b/app/bot.js index ac2f13e..30ef1cd 100644 --- a/app/bot.js +++ b/app/bot.js @@ -1,6 +1,13 @@ const GuildData = require("./models/guild-data.js"); module.exports = { + onReady(client, guildsData, config) { + return new Promise((resolve, reject) => { + parseLinksInGuilds(client.guilds, guildsData) + .then(() => checkFeedsInGuilds(client.guilds, guildsData)) + .then(() => setInterval(() => checkFeedsInGuilds(client.guilds, guildsData), config.feedCheckIntervalSec * 1000)); //set up an interval to check all the feeds + }); + }, onCommand(commandObj, commandsObj, params, guildData, message) { switch (commandObj.command) { case commandsObj.addFeed.command: diff --git a/app/index.js b/app/index.js index 759e2b7..ebd686f 100644 --- a/app/index.js +++ b/app/index.js @@ -38,6 +38,8 @@ module.exports = (client, config = null) => { HandleMessage.text(client, config, message, guildsData); } }); + + Bot.onReady(client, guildsData, config).then(() => writeFile).catch(err => DiscordUtil.dateError(err)); }; const HandleMessage = {