3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-18 15:45:03 +00:00

Automod work. Add config examples to automod.

This commit is contained in:
Dragory 2019-10-11 01:59:56 +03:00
parent a6cc1d646e
commit def46941c9
11 changed files with 539 additions and 258 deletions

View file

@ -1,5 +1,7 @@
import {
Attachment,
Client,
Embed,
EmbedOptions,
Emoji,
Guild,
@ -23,6 +25,7 @@ const fsp = fs.promises;
import https from "https";
import tmp from "tmp";
import { logger, waitForReaction } from "knub";
import { SavedMessage } from "./data/entities/SavedMessage";
const delayStringMultipliers = {
w: 1000 * 60 * 60 * 24 * 7,
@ -772,3 +775,20 @@ export async function confirm(bot: Client, channel: TextableChannel, userId: str
msg.delete().catch(noop);
return reply && reply.name === "✅";
}
export function messageSummary(msg: SavedMessage) {
// Regular text content
let result = "```" + (msg.data.content ? disableCodeBlocks(msg.data.content) : "<no text content>") + "```";
// Rich embed
const richEmbed = (msg.data.embeds || []).find(e => (e as Embed).type === "rich");
if (richEmbed) result += "Embed:```" + disableCodeBlocks(JSON.stringify(richEmbed)) + "```";
// Attachments
if (msg.data.attachments) {
result +=
"Attachments:\n" + msg.data.attachments.map((a: Attachment) => disableLinkPreviews(a.url)).join("\n") + "\n";
}
return result;
}