Add pagination limit to config
This commit is contained in:
parent
db86cacaa0
commit
538732cbf4
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
## Unreleased
|
## 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
|
- Fix articles not posting if contents too long for a single discord message
|
||||||
|
|
||||||
## v3.1.2
|
## v3.1.2
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
const Core = require("../../discord-bot-core");
|
const Core = require("../../discord-bot-core");
|
||||||
|
const Config = require("../config.json");
|
||||||
|
|
||||||
module.exports = new Core.Command({
|
module.exports = new Core.Command({
|
||||||
name: "view-feeds",
|
name: "view-feeds",
|
||||||
|
@ -12,9 +13,8 @@ function invoke({ message, params, guildData, client }) {
|
||||||
if (!guildData)
|
if (!guildData)
|
||||||
return Promise.reject("Guild not setup");
|
return Promise.reject("Guild not setup");
|
||||||
|
|
||||||
const numToShow = 10;
|
const startIdx = params[0] ? (params[0] - 1) * Config.viewFeedsPaginationLimit : 0;
|
||||||
const startIdx = params[0] ? (params[0] - 1) * numToShow : 0;
|
const endIdx = startIdx + Config.viewFeedsPaginationLimit + 1;
|
||||||
const endIdx = startIdx + numToShow + 1;
|
|
||||||
|
|
||||||
let responseStr = guildData.feeds.map(f => f.toString()).slice(startIdx, endIdx).join("\n");
|
let responseStr = guildData.feeds.map(f => f.toString()).slice(startIdx, endIdx).join("\n");
|
||||||
if (guildData.feeds.length > endIdx)
|
if (guildData.feeds.length > endIdx)
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
{
|
{
|
||||||
"maxCacheSize": 100,
|
"maxCacheSize": 100,
|
||||||
"feedCheckIntervalSec": 30,
|
"feedCheckIntervalSec": 30,
|
||||||
"charLimit": 500
|
"charLimit": 500,
|
||||||
|
"viewFeedsPaginationLimit": 10
|
||||||
}
|
}
|
Loading…
Reference in New Issue