const {addCommand} = require("../lib/command"); const {startPrompt} = require("../lib/prompt"); const {processMessage} = require("../lib/messages"); async function getHistory(limit = 20) { if (!comcord.state.currentChannel) { console.log(""); return; } const messages = await comcord.client.guilds .get(comcord.state.currentGuild) .channels.get(comcord.state.currentChannel) .getMessages({limit}); messages.reverse(); console.log("--Beginning-Review".padEnd(72, "-")); for (const msg of messages) { processMessage(msg, {noColor: true, history: true}); } console.log("--Review-Complete".padEnd(73, "-")); } async function getExtendedHistory(input) { input = parseInt(input); if (isNaN(input)) { console.log(""); return; } try { await getHistory(input); } catch (err) { console.log(""); } } addCommand("r", "channel history", getHistory); addCommand("R", "extended history", function () { startPrompt(":lines> ", async function (input) { process.stdout.write("\n"); await getExtendedHistory(input); }); });