From 538732cbf470ed2012094325037b3dc2f796e095 Mon Sep 17 00:00:00 2001 From: benji7425 Date: Mon, 27 Nov 2017 00:07:29 +0000 Subject: [PATCH] Add pagination limit to config --- CHANGELOG.md | 1 + app/commands/view-feeds.js | 6 +++--- app/config.json | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f46872e..d4b735d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Unreleased +- Add rudimentary pagination for viewing feeds when there are more than 10 - Fix articles not posting if contents too long for a single discord message ## v3.1.2 diff --git a/app/commands/view-feeds.js b/app/commands/view-feeds.js index 1640761..bda6219 100644 --- a/app/commands/view-feeds.js +++ b/app/commands/view-feeds.js @@ -1,4 +1,5 @@ const Core = require("../../discord-bot-core"); +const Config = require("../config.json"); module.exports = new Core.Command({ name: "view-feeds", @@ -12,9 +13,8 @@ function invoke({ message, params, guildData, client }) { if (!guildData) return Promise.reject("Guild not setup"); - const numToShow = 10; - const startIdx = params[0] ? (params[0] - 1) * numToShow : 0; - const endIdx = startIdx + numToShow + 1; + const startIdx = params[0] ? (params[0] - 1) * Config.viewFeedsPaginationLimit : 0; + const endIdx = startIdx + Config.viewFeedsPaginationLimit + 1; let responseStr = guildData.feeds.map(f => f.toString()).slice(startIdx, endIdx).join("\n"); if (guildData.feeds.length > endIdx) diff --git a/app/config.json b/app/config.json index 52d914c..1c22446 100644 --- a/app/config.json +++ b/app/config.json @@ -1,5 +1,6 @@ { "maxCacheSize": 100, "feedCheckIntervalSec": 30, - "charLimit": 500 + "charLimit": 500, + "viewFeedsPaginationLimit": 10 } \ No newline at end of file