Add !message/!messageinfo command

This commit is contained in:
Dragory 2020-08-06 00:46:47 +03:00
parent 60aff76ebe
commit e8ff297368
No known key found for this signature in database
GPG key ID: 5F387BA66DF8AAC1
9 changed files with 210 additions and 0 deletions

View file

@ -0,0 +1,31 @@
import { utilityCmd } from "../types";
import { commandTypeHelpers as ct } from "../../../commandTypes";
import { sendErrorMessage } from "../../../pluginUtils";
import { getMessageInfoEmbed } from "../functions/getMessageInfoEmbed";
import { canReadChannel } from "../../../utils/canReadChannel";
export const MessageInfoCmd = utilityCmd({
trigger: ["message", "messageinfo"],
description: "Show information about a message",
usage: "!message 534722016549404673-534722219696455701",
permission: "can_message",
signature: {
message: ct.messageTarget(),
},
async run({ message, args, pluginData }) {
if (!canReadChannel(args.message.channel, message.author.id)) {
sendErrorMessage(pluginData, message.channel, "Unknown message");
return;
}
const embed = await getMessageInfoEmbed(pluginData, args.message.channel.id, args.message.messageId);
if (!embed) {
sendErrorMessage(pluginData, message.channel, "Unknown message");
return;
}
message.channel.createMessage({ embed });
},
});