mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-20 00:05:04 +00:00
Combine Knub's type helpers with Zeppelin's, continue Utility plugin port
This commit is contained in:
parent
383601e9f4
commit
16ab3c36c4
13 changed files with 533 additions and 13 deletions
32
backend/src/plugins/Utility/commands/ContextCmd.ts
Normal file
32
backend/src/plugins/Utility/commands/ContextCmd.ts
Normal file
|
@ -0,0 +1,32 @@
|
|||
import { utilityCmd } from "../types";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { messageLink } from "../../../utils";
|
||||
import { sendErrorMessage } from "../../../pluginUtils";
|
||||
import { TextChannel } from "eris";
|
||||
|
||||
export const ContextCmd = utilityCmd({
|
||||
trigger: "context",
|
||||
description: "Get a link to the context of the specified message",
|
||||
usage: "!context 94882524378968064 650391267720822785",
|
||||
permission: "can_context",
|
||||
|
||||
signature: {
|
||||
channel: ct.channel(),
|
||||
messageId: ct.string(),
|
||||
},
|
||||
|
||||
async run({ message: msg, args, pluginData }) {
|
||||
if (!(args.channel instanceof TextChannel)) {
|
||||
sendErrorMessage(pluginData, msg.channel, "Channel must be a text channel");
|
||||
return;
|
||||
}
|
||||
|
||||
const previousMessage = (await this.bot.getMessages(args.channel.id, 1, args.messageId))[0];
|
||||
if (!previousMessage) {
|
||||
sendErrorMessage(pluginData, msg.channel, "Message context not found");
|
||||
return;
|
||||
}
|
||||
|
||||
msg.channel.createMessage(messageLink(this.guildId, previousMessage.channel.id, previousMessage.id));
|
||||
},
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue