2017-09-24 23:31:30 +03:00
|
|
|
const Core = require("../../discord-bot-core");
|
2017-11-27 02:07:29 +02:00
|
|
|
const Config = require("../config.json");
|
2017-09-24 23:31:30 +03:00
|
|
|
|
|
|
|
module.exports = new Core.Command({
|
|
|
|
name: "view-feeds",
|
|
|
|
description: "View a list of configured feeds and their associated details",
|
|
|
|
syntax: "view-feed",
|
|
|
|
admin: true,
|
|
|
|
invoke: invoke
|
|
|
|
});
|
|
|
|
|
|
|
|
function invoke({ message, params, guildData, client }) {
|
|
|
|
if (!guildData)
|
2017-09-25 00:46:58 +03:00
|
|
|
return Promise.reject("Guild not setup");
|
2017-09-24 23:31:30 +03:00
|
|
|
|
2017-11-27 02:07:29 +02:00
|
|
|
const startIdx = params[0] ? (params[0] - 1) * Config.viewFeedsPaginationLimit : 0;
|
|
|
|
const endIdx = startIdx + Config.viewFeedsPaginationLimit + 1;
|
2017-11-27 02:02:39 +02:00
|
|
|
|
|
|
|
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`;
|
2017-12-07 03:35:00 +02:00
|
|
|
return Promise.resolve(responseStr || "No feeds configured");
|
2017-09-24 23:31:30 +03:00
|
|
|
}
|