Add rudimentary pagination for viewing feeds
This commit is contained in:
parent
8f1c840447
commit
4c7d826b52
|
@ -1,5 +1,9 @@
|
|||
# Changelog
|
||||
|
||||
## Unreleased
|
||||
|
||||
- Fix articles not posting if contents too long for a single discord message
|
||||
|
||||
## v3.1.2
|
||||
|
||||
### Fixed
|
||||
|
|
|
@ -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);
|
||||
}
|
|
@ -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 => {
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue