diff --git a/src/commands/history.js b/src/commands/history.js index 7067b07..890e6ba 100644 --- a/src/commands/history.js +++ b/src/commands/history.js @@ -1,15 +1,16 @@ const {addCommand} = require("../lib/command"); const {startPrompt} = require("../lib/prompt"); const {processMessage} = require("../lib/messages"); +const {listChannels} = require("./listChannels"); -async function getHistory(limit = 20) { - if (!comcord.state.currentChannel) { +async function getHistory(limit = 20, channel = null) { + if (!channel && !comcord.state.currentChannel) { console.log(""); return; } const messages = await comcord.client.getMessages( - comcord.state.currentChannel, + channel ?? comcord.state.currentChannel, {limit} ); messages.reverse(); @@ -44,3 +45,35 @@ addCommand("R", "extended history", function () { await getExtendedHistory(input); }); }); +addCommand("p", "peek at channel", function () { + if (!comcord.state.currentGuild) { + console.log(""); + return; + } + + listChannels(); + startPrompt(":peek> ", async function (input) { + console.log(""); + if (input == "") { + return; + } + let target; + + const guild = comcord.client.guilds.get(comcord.state.currentGuild); + const channels = [...guild.channels.values()].filter((c) => c.type == 0); + channels.sort((a, b) => a.position - b.position); + + for (const channel of channels) { + if (channel.name.toLowerCase().indexOf(input.toLowerCase()) > -1) { + target = channel.id; + break; + } + } + + if (target == null) { + console.log(""); + } else { + await getHistory(20, target); + } + }); +}); diff --git a/src/index.js b/src/index.js index e6a19f9..86aa96f 100644 --- a/src/index.js +++ b/src/index.js @@ -267,6 +267,7 @@ client.on("messageReactionAdd", async function (msg, emoji, reactor) { referencedMessage: reply, author: reactor?.user ?? client.users.get(reactor.id), timestamp: Date.now(), + mentions: [], content: `*reacted with ${emoji.id ? `:${emoji.name}:` : emoji.name}*`, };