diff --git a/app/commands/add-feed.js b/app/commands/add-feed.js index 9116471..9a7bcc0 100644 --- a/app/commands/add-feed.js +++ b/app/commands/add-feed.js @@ -29,22 +29,20 @@ function invoke({ message, params, guildData, client }) { maxCacheSize: Config.maxCacheSize }); - return new Promise((resolve, reject) => { - //ask the user if they're happy with the details they set up, save if yes, don't if no - Core.util.ask(client, message.channel, message.member, "Are you happy with this (yes/no)?\n" + feedData.toString()) - .then(responseMessage => { + //ask the user if they're happy with the details they set up, save if yes, don't if no + Core.util.ask(client, message.channel, message.member, "Are you happy with this (yes/no)?\n" + feedData.toString()) + .then(responseMessage => { - //if they responded yes, save the feed and let them know, else tell them to start again - if (responseMessage.content.toLowerCase() === "yes") { - if (!guildData) - guildData = new GuildData({ id: message.guild.id, feeds: [] }); + //if they responded yes, save the feed and let them know, else tell them to start again + if (responseMessage.content.toLowerCase() === "yes") { + if (!guildData) + guildData = new GuildData({ id: message.guild.id, feeds: [] }); - guildData.feeds.push(feedData); - guildData.cachePastPostedLinks(message.guild) - .then(() => resolve("Your new feed has been saved!")); - } - else - reject("Your feed has not been saved, please add it again with the correct details"); - }); - }); + guildData.feeds.push(feedData); + guildData.cachePastPostedLinks(message.guild) + .then(() => message.reply("Your new feed has been saved!")); + } + else + message.reply("Your feed has not been saved, please add it again with the correct details"); + }); } \ No newline at end of file diff --git a/app/commands/on-text-message.js b/app/commands/on-text-message.js deleted file mode 100644 index e69de29..0000000 diff --git a/app/commands/remove-feed.js b/app/commands/remove-feed.js index c16990f..74d8f99 100644 --- a/app/commands/remove-feed.js +++ b/app/commands/remove-feed.js @@ -11,8 +11,8 @@ module.exports = new Core.Command({ function invoke({ message, params, guildData, client }) { const idx = guildData.feeds.findIndex(feed => feed.id === params[2]); if (!Number.isInteger(idx)) - return Promise.reject("Can't find feed with id " + params[2]); + message.reply("Can't find feed with id " + params[2]); guildData.feeds.splice(idx, 1); - return Promise.resolve("Feed removed!"); + message.reply("Feed removed!"); } \ No newline at end of file diff --git a/app/commands/view-feeds.js b/app/commands/view-feeds.js index 1ff56c3..4f218f6 100644 --- a/app/commands/view-feeds.js +++ b/app/commands/view-feeds.js @@ -10,7 +10,7 @@ module.exports = new Core.Command({ function invoke({ message, params, guildData, client }) { if (!guildData) - return Promise.reject("Guild not setup"); + message.reply("Guild not setup"); - return Promise.resolve(guildData.feeds.map(f => f.toString()).join("\n")); + message.reply(guildData.feeds.map(f => f.toString()).join("\n")); } \ No newline at end of file diff --git a/app/index.js b/app/index.js index 36f9ad5..0ff26b3 100644 --- a/app/index.js +++ b/app/index.js @@ -13,17 +13,18 @@ client.on("beforeLogin", () => { setInterval(() => checkFeedsInGuilds(client.guilds, client.guildsData), Config.feedCheckIntervalSec * 1000); }); -client.on("ready", (coreClient) => { - parseLinksInGuilds(coreClient.actual.guilds, coreClient.guildsData) - .then(() => checkFeedsInGuilds(coreClient.actual.guilds, coreClient.guildsData)); +client.on("ready", () => { + parseLinksInGuilds(client.guilds, client.guildsData) + .then(() => checkFeedsInGuilds(client.guilds, client.guildsData)); }); client.on("message", message => { const guildData = client.guildsData[message.guild.id]; - guildData.feeds.forEach(feedData => { - if (message.channel.name === feedData.channelName) - feedData.cachedLinks.push(...GetUrls(message.content)); - }); + if (guildData) + guildData.feeds.forEach(feedData => { + if (message.channel.name === feedData.channelName) + feedData.cachedLinks.push(...GetUrls(message.content)); + }); }); client.bootstrap();