Add pagination limit to config

This commit is contained in:
benji7425 2017-11-27 00:07:29 +00:00
parent 4c7d826b52
commit 3e24a63a86
3 changed files with 6 additions and 4 deletions

View File

@ -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

View File

@ -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)

View File

@ -1,5 +1,6 @@
{
"maxCacheSize": 100,
"feedCheckIntervalSec": 30,
"charLimit": 500
"charLimit": 500,
"viewFeedsPaginationLimit": 10
}