Browse Source

Add pagination limit to config

shorten
benji7425 3 years ago
parent
commit
538732cbf4
  1. 1
      CHANGELOG.md
  2. 6
      app/commands/view-feeds.js
  3. 3
      app/config.json

1
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

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

3
app/config.json

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