Add rudimentary pagination for viewing feeds

This commit is contained in:
benji7425 2017-11-27 00:02:39 +00:00
parent 21c51fbc3d
commit db86cacaa0
4 changed files with 12 additions and 7 deletions

View File

@ -1,5 +1,9 @@
# Changelog
## Unreleased
- Fix articles not posting if contents too long for a single discord message
## v3.1.2
### Fixed

View File

@ -12,5 +12,12 @@ function invoke({ message, params, guildData, client }) {
if (!guildData)
return Promise.reject("Guild not setup");
return Promise.resolve(guildData.feeds.map(f => f.toString()).join("\n"));
const numToShow = 10;
const startIdx = params[0] ? (params[0] - 1) * numToShow : 0;
const endIdx = startIdx + numToShow + 1;
let responseStr = guildData.feeds.map(f => f.toString()).slice(startIdx, endIdx).join("\n");
if (guildData.feeds.length > endIdx)
responseStr += `Use *view-feeds ${startIdx + 2}* to view more`;
return Promise.resolve(responseStr);
}

View File

@ -92,10 +92,6 @@ module.exports = class Client extends Discord.Client {
err => { if (err) CoreUtil.dateError(`Error writing data file! ${err.message || err}`); });
}
/**
* @param {*} json
* @param {*} guildDataModel
*/
fromJSON(json) {
const guildsData = Object.keys(json);
guildsData.forEach(guildID => {

View File

@ -4,7 +4,6 @@ const ParentPackageJSON = require("../package.json");
// @ts-ignore
const InternalConfig = require("./internal-config.json");
/**@param param*/
function handleMessage(client, message, commands, guildData) {
if (!message.content.startsWith(message.guild.me.toString()) //criteria for a command is the bot being tagged
&& !message.content.startsWith(message.guild.me.toString().replace("!", ""))) //hacky fix for android mentions not including an exclamation mark
@ -33,7 +32,6 @@ function handleMessage(client, message, commands, guildData) {
});
}
/**@param param*/
function handleInternalCommand(message, split, commands, isMemberAdmin) {
if (!split[1])
return;