3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-03-16 22:21:51 +00:00

djs typings: Attachment & Util

Signed-off-by: GitHub <noreply@github.com>
This commit is contained in:
metal 2023-03-11 14:41:04 +00:00 committed by GitHub
parent aad4ad82a5
commit 010451c7e7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 49 additions and 44 deletions

View file

@ -1,4 +1,4 @@
import { MessageAttachment } from "discord.js"; import { Attachment } from "discord.js";
import { Column, Entity, PrimaryColumn, PrimaryGeneratedColumn } from "typeorm"; import { Column, Entity, PrimaryColumn, PrimaryGeneratedColumn } from "typeorm";
import { StrictMessageContent } from "../../utils"; import { StrictMessageContent } from "../../utils";
@ -17,7 +17,7 @@ export class ScheduledPost {
@Column("simple-json") content: StrictMessageContent; @Column("simple-json") content: StrictMessageContent;
@Column("simple-json") attachments: MessageAttachment[]; @Column("simple-json") attachments: Attachment[];
@Column({ type: String, nullable: true }) post_at: string | null; @Column({ type: String, nullable: true }) post_at: string | null;

View file

@ -1,4 +1,4 @@
import { Snowflake, TextChannel, Util } from "discord.js"; import { escapeInlineCode, Snowflake, TextChannel } from "discord.js";
import * as t from "io-ts"; import * as t from "io-ts";
import { asSingleLine, messageSummary, verboseChannelMention } from "../../../utils"; import { asSingleLine, messageSummary, verboseChannelMention } from "../../../utils";
import { automodTrigger } from "../helpers"; import { automodTrigger } from "../helpers";
@ -71,7 +71,7 @@ export const MatchAttachmentTypeTrigger = automodTrigger<MatchResultType>()({
return ( return (
asSingleLine(` asSingleLine(`
Matched attachment type \`${Util.escapeInlineCode(matchResult.extra.matchedType)}\` Matched attachment type \`${escapeInlineCode(matchResult.extra.matchedType)}\`
(${matchResult.extra.mode === "blacklist" ? "blacklisted" : "not in whitelist"}) (${matchResult.extra.mode === "blacklist" ? "blacklisted" : "not in whitelist"})
in message (\`${contexts[0].message!.id}\`) in ${prettyChannel}: in message (\`${contexts[0].message!.id}\`) in ${prettyChannel}:
`) + messageSummary(contexts[0].message!) `) + messageSummary(contexts[0].message!)

View file

@ -1,4 +1,3 @@
import { Util } from "discord.js";
import escapeStringRegexp from "escape-string-regexp"; import escapeStringRegexp from "escape-string-regexp";
import * as t from "io-ts"; import * as t from "io-ts";
import { allowTimeout } from "../../../RegExpRunner"; import { allowTimeout } from "../../../RegExpRunner";
@ -11,6 +10,7 @@ import { mergeRegexes } from "../../../utils/mergeRegexes";
import { mergeWordsIntoRegex } from "../../../utils/mergeWordsIntoRegex"; import { mergeWordsIntoRegex } from "../../../utils/mergeWordsIntoRegex";
import { PhishermanPlugin } from "../../Phisherman/PhishermanPlugin"; import { PhishermanPlugin } from "../../Phisherman/PhishermanPlugin";
import { phishermanDomainIsSafe } from "../../../data/Phisherman"; import { phishermanDomainIsSafe } from "../../../data/Phisherman";
import { escapeInlineCode } from "discord.js";
interface MatchResultType { interface MatchResultType {
type: MatchableTextType; type: MatchableTextType;
@ -186,7 +186,7 @@ export const MatchLinksTrigger = automodTrigger<MatchResultType>()({
renderMatchInformation({ pluginData, contexts, matchResult }) { renderMatchInformation({ pluginData, contexts, matchResult }) {
const partialSummary = getTextMatchPartialSummary(pluginData, matchResult.extra.type, contexts[0]); const partialSummary = getTextMatchPartialSummary(pluginData, matchResult.extra.type, contexts[0]);
let information = `Matched link \`${Util.escapeInlineCode(matchResult.extra.link)}\``; let information = `Matched link \`${escapeInlineCode(matchResult.extra.link)}\``;
if (matchResult.extra.details) { if (matchResult.extra.details) {
information += ` ${matchResult.extra.details}`; information += ` ${matchResult.extra.details}`;
} }

View file

@ -1,7 +1,7 @@
import { automodTrigger } from "../helpers"; import { automodTrigger } from "../helpers";
import * as t from "io-ts"; import * as t from "io-ts";
import { asSingleLine, messageSummary, verboseChannelMention } from "../../../utils"; import { asSingleLine, messageSummary, verboseChannelMention } from "../../../utils";
import { GuildChannel, Util } from "discord.js"; import { escapeInlineCode, GuildChannel } from "discord.js";
interface MatchResultType { interface MatchResultType {
matchedType: string; matchedType: string;
@ -71,7 +71,7 @@ export const MatchMimeTypeTrigger = automodTrigger<MatchResultType>()({
return ( return (
asSingleLine(` asSingleLine(`
Matched MIME type \`${Util.escapeInlineCode(matchedType)}\` Matched MIME type \`${escapeInlineCode(matchedType)}\`
(${mode === "blacklist" ? "blacklisted" : "not in whitelist"}) (${mode === "blacklist" ? "blacklisted" : "not in whitelist"})
in message (\`${message!.id}\`) in ${prettyChannel} in message (\`${message!.id}\`) in ${prettyChannel}
`) + messageSummary(message!) `) + messageSummary(message!)

View file

@ -1,4 +1,3 @@
import { Util } from "discord.js";
import escapeStringRegexp from "escape-string-regexp"; import escapeStringRegexp from "escape-string-regexp";
import * as t from "io-ts"; import * as t from "io-ts";
import { normalizeText } from "../../../utils/normalizeText"; import { normalizeText } from "../../../utils/normalizeText";

View file

@ -1,5 +1,5 @@
import { Snowflake } from "discord-api-types/v9"; import { Snowflake } from "discord-api-types/v9";
import { User, Util } from "discord.js"; import { escapeBold, User } from "discord.js";
import * as t from "io-ts"; import * as t from "io-ts";
import { tNullable } from "../../../utils"; import { tNullable } from "../../../utils";
import { automodTrigger } from "../helpers"; import { automodTrigger } from "../helpers";
@ -49,7 +49,7 @@ export const ThreadArchiveTrigger = automodTrigger<ThreadArchiveResult>()({
const parentName = matchResult.extra.matchedThreadParentName; const parentName = matchResult.extra.matchedThreadParentName;
const base = `Thread **#${threadName}** (\`${threadId}\`) has been archived in the **#${parentName}** (\`${parentId}\`) channel`; const base = `Thread **#${threadName}** (\`${threadId}\`) has been archived in the **#${parentName}** (\`${parentId}\`) channel`;
if (threadOwner) { if (threadOwner) {
return `${base} by **${Util.escapeBold(threadOwner.tag)}** (\`${threadOwner.id}\`)`; return `${base} by **${escapeBold(threadOwner.tag)}** (\`${threadOwner.id}\`)`;
} }
return base; return base;
}, },

View file

@ -1,5 +1,5 @@
import { Snowflake } from "discord-api-types/v9"; import { Snowflake } from "discord-api-types/v9";
import { User, Util } from "discord.js"; import { escapeBold, User } from "discord.js";
import * as t from "io-ts"; import * as t from "io-ts";
import { automodTrigger } from "../helpers"; import { automodTrigger } from "../helpers";
@ -41,7 +41,7 @@ export const ThreadCreateTrigger = automodTrigger<ThreadCreateResult>()({
const parentName = matchResult.extra.matchedThreadParentName; const parentName = matchResult.extra.matchedThreadParentName;
const base = `Thread **#${threadName}** (\`${threadId}\`) has been created in the **#${parentName}** (\`${parentId}\`) channel`; const base = `Thread **#${threadName}** (\`${threadId}\`) has been created in the **#${parentName}** (\`${parentId}\`) channel`;
if (threadOwner) { if (threadOwner) {
return `${base} by **${Util.escapeBold(threadOwner.tag)}** (\`${threadOwner.id}\`)`; return `${base} by **${escapeBold(threadOwner.tag)}** (\`${threadOwner.id}\`)`;
} }
return base; return base;
}, },

View file

@ -1,5 +1,5 @@
import { Snowflake } from "discord-api-types/v9"; import { Snowflake } from "discord-api-types/v9";
import { User, Util } from "discord.js"; import { escapeBold, User } from "discord.js";
import * as t from "io-ts"; import * as t from "io-ts";
import { automodTrigger } from "../helpers"; import { automodTrigger } from "../helpers";
@ -40,7 +40,7 @@ export const ThreadDeleteTrigger = automodTrigger<ThreadDeleteResult>()({
const parentId = matchResult.extra.matchedThreadParentId; const parentId = matchResult.extra.matchedThreadParentId;
const parentName = matchResult.extra.matchedThreadParentName; const parentName = matchResult.extra.matchedThreadParentName;
if (threadOwner) { if (threadOwner) {
return `Thread **#${threadName ?? "Unknown"}** (\`${threadId}\`) created by **${Util.escapeBold( return `Thread **#${threadName ?? "Unknown"}** (\`${threadId}\`) created by **${escapeBold(
threadOwner.tag, threadOwner.tag,
)}** (\`${threadOwner.id}\`) in the **#${parentName}** (\`${parentId}\`) channel has been deleted`; )}** (\`${threadOwner.id}\`) in the **#${parentName}** (\`${parentId}\`) channel has been deleted`;
} }

View file

@ -1,5 +1,5 @@
import { Snowflake } from "discord-api-types/v9"; import { Snowflake } from "discord-api-types/v9";
import { User, Util } from "discord.js"; import { escapeBold, User } from "discord.js";
import * as t from "io-ts"; import * as t from "io-ts";
import { tNullable } from "../../../utils"; import { tNullable } from "../../../utils";
import { automodTrigger } from "../helpers"; import { automodTrigger } from "../helpers";
@ -49,7 +49,7 @@ export const ThreadUnarchiveTrigger = automodTrigger<ThreadUnarchiveResult>()({
const parentName = matchResult.extra.matchedThreadParentName; const parentName = matchResult.extra.matchedThreadParentName;
const base = `Thread **#${threadName}** (\`${threadId}\`) has been unarchived in the **#${parentName}** (\`${parentId}\`) channel`; const base = `Thread **#${threadName}** (\`${threadId}\`) has been unarchived in the **#${parentName}** (\`${parentId}\`) channel`;
if (threadOwner) { if (threadOwner) {
return `${base} by **${Util.escapeBold(threadOwner.tag)}** (\`${threadOwner.id}\`)`; return `${base} by **${escapeBold(threadOwner.tag)}** (\`${threadOwner.id}\`)`;
} }
return base; return base;
}, },

View file

@ -1,4 +1,4 @@
import { MessageEditOptions, MessageOptions, Util } from "discord.js"; import { escapeCodeBlock, MessageEditOptions, MessageOptions } from "discord.js";
import { GuildPluginData } from "knub"; import { GuildPluginData } from "knub";
import moment from "moment-timezone"; import moment from "moment-timezone";
import { CaseTypes } from "../../../data/CaseTypes"; import { CaseTypes } from "../../../data/CaseTypes";
@ -67,7 +67,7 @@ export async function getCaseEmbed(
if (theCase.notes.length) { if (theCase.notes.length) {
for (const note of theCase.notes) { for (const note of theCase.notes) {
const noteDate = moment.utc(note.created_at); const noteDate = moment.utc(note.created_at);
let noteBody = Util.escapeCodeBlock(note.body.trim()); let noteBody = escapeCodeBlock(note.body.trim());
if (noteBody === "") { if (noteBody === "") {
noteBody = emptyEmbedValue; noteBody = emptyEmbedValue;
} }

View file

@ -35,7 +35,6 @@ import { log } from "./util/log";
import { onMessageDelete } from "./util/onMessageDelete"; import { onMessageDelete } from "./util/onMessageDelete";
import { onMessageDeleteBulk } from "./util/onMessageDeleteBulk"; import { onMessageDeleteBulk } from "./util/onMessageDeleteBulk";
import { onMessageUpdate } from "./util/onMessageUpdate"; import { onMessageUpdate } from "./util/onMessageUpdate";
import { Util } from "discord.js";
import { import {
createTypedTemplateSafeValueContainer, createTypedTemplateSafeValueContainer,
TemplateSafeValueContainer, TemplateSafeValueContainer,
@ -113,6 +112,7 @@ import { logVoiceChannelMove } from "./logFunctions/logVoiceChannelMove";
import { logMemberTimedUnban } from "./logFunctions/logMemberTimedUnban"; import { logMemberTimedUnban } from "./logFunctions/logMemberTimedUnban";
import { logDmFailed } from "./logFunctions/logDmFailed"; import { logDmFailed } from "./logFunctions/logDmFailed";
import { InternalPosterPlugin } from "../InternalPoster/InternalPosterPlugin"; import { InternalPosterPlugin } from "../InternalPoster/InternalPosterPlugin";
import { escapeCodeBlock } from "discord.js";
const defaultOptions: PluginOptions<LogsPluginType> = { const defaultOptions: PluginOptions<LogsPluginType> = {
config: { config: {
@ -300,7 +300,7 @@ export const LogsPlugin = zeppelinGuildPlugin<LogsPluginType>()({
The following regex has taken longer than ${timeoutMs}ms for ${failedTimes} times and has been temporarily disabled: The following regex has taken longer than ${timeoutMs}ms for ${failedTimes} times and has been temporarily disabled:
`.trim() + `.trim() +
"\n```" + "\n```" +
Util.escapeCodeBlock(regexSource) + escapeCodeBlock(regexSource) +
"```", "```",
}), }),
); );

View file

@ -1,6 +1,6 @@
import { MessageAttachment } from "discord.js"; import { Attachment } from "discord.js";
export function formatReasonWithAttachments(reason: string, attachments: MessageAttachment[]) { export function formatReasonWithAttachments(reason: string, attachments: Attachment[]) {
const attachmentUrls = attachments.map((a) => a.url); const attachmentUrls = attachments.map((a) => a.url);
return ((reason || "") + " " + attachmentUrls.join(" ")).trim(); return ((reason || "") + " " + attachmentUrls.join(" ")).trim();
} }

View file

@ -1,4 +1,4 @@
import { Util } from "discord.js"; import { escapeCodeBlock } from "discord.js";
import humanizeDuration from "humanize-duration"; import humanizeDuration from "humanize-duration";
import moment from "moment-timezone"; import moment from "moment-timezone";
import { createChunkedMessage, DBDateFormat, deactivateMentions, sorter, trimLines } from "../../../utils"; import { createChunkedMessage, DBDateFormat, deactivateMentions, sorter, trimLines } from "../../../utils";
@ -26,7 +26,7 @@ export const ScheduledPostsListCmd = postCmd({
const isTruncated = previewText.length > SCHEDULED_POST_PREVIEW_TEXT_LENGTH; const isTruncated = previewText.length > SCHEDULED_POST_PREVIEW_TEXT_LENGTH;
previewText = Util.escapeCodeBlock(deactivateMentions(previewText)) previewText = escapeCodeBlock(deactivateMentions(previewText))
.replace(/\s+/g, " ") .replace(/\s+/g, " ")
.slice(0, SCHEDULED_POST_PREVIEW_TEXT_LENGTH); .slice(0, SCHEDULED_POST_PREVIEW_TEXT_LENGTH);

View file

@ -1,7 +1,7 @@
import { import {
Attachment,
GuildTextBasedChannel, GuildTextBasedChannel,
Message, Message,
MessageAttachment,
MessageOptions, MessageOptions,
NewsChannel, NewsChannel,
TextChannel, TextChannel,
@ -19,7 +19,7 @@ export async function postMessage(
pluginData: GuildPluginData<PostPluginType>, pluginData: GuildPluginData<PostPluginType>,
channel: GuildTextBasedChannel, channel: GuildTextBasedChannel,
content: MessageOptions, content: MessageOptions,
attachments: MessageAttachment[] = [], attachments: Attachment[] = [],
enableMentions: boolean = false, enableMentions: boolean = false,
): Promise<Message> { ): Promise<Message> {
if (typeof content === "string") { if (typeof content === "string") {

View file

@ -1,4 +1,11 @@
import { ChannelType, GuildTextBasedChannel, PermissionsBitField, TextChannel, ThreadChannel, Util } from "discord.js"; import {
ChannelType,
escapeInlineCode,
GuildTextBasedChannel,
PermissionsBitField,
TextChannel,
ThreadChannel,
} from "discord.js";
import humanizeDuration from "humanize-duration"; import humanizeDuration from "humanize-duration";
import { commandTypeHelpers as ct } from "../../../commandTypes"; import { commandTypeHelpers as ct } from "../../../commandTypes";
import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils"; import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
@ -132,7 +139,7 @@ export const SlowmodeSetCmd = slowmodeCmd({
rateLimitPerUser: rateLimitSeconds, rateLimitPerUser: rateLimitSeconds,
}); });
} catch (e) { } catch (e) {
sendErrorMessage(pluginData, msg.channel, `Failed to set native slowmode: ${Util.escapeInlineCode(e.message)}`); sendErrorMessage(pluginData, msg.channel, `Failed to set native slowmode: ${escapeInlineCode(e.message)}`);
return; return;
} }
} else { } else {

View file

@ -1,4 +1,4 @@
import { Util } from "discord.js"; import { escapeInlineCode } from "discord.js";
import { commandTypeHelpers as ct } from "../../../commandTypes"; import { commandTypeHelpers as ct } from "../../../commandTypes";
import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils"; import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
import { trimLines } from "../../../utils"; import { trimLines } from "../../../utils";
@ -20,7 +20,7 @@ export const SetTimezoneCmd = timeAndDateCmd({
pluginData, pluginData,
message.channel, message.channel,
trimLines(` trimLines(`
Invalid timezone: \`${Util.escapeInlineCode(args.timezone)}\` Invalid timezone: \`${escapeInlineCode(args.timezone)}\`
Zeppelin uses timezone locations rather than specific timezone names. Zeppelin uses timezone locations rather than specific timezone names.
See the **TZ database name** column at <https://en.wikipedia.org/wiki/List_of_tz_database_time_zones> for a list of valid options. See the **TZ database name** column at <https://en.wikipedia.org/wiki/List_of_tz_database_time_zones> for a list of valid options.
`), `),

View file

@ -1,4 +1,4 @@
import { MessageAttachment } from "discord.js"; import { Attachment, AttachmentBuilder } from "discord.js";
import fs from "fs"; import fs from "fs";
import photon from "@silvia-odwyer/photon-node"; import photon from "@silvia-odwyer/photon-node";
import twemoji from "twemoji"; import twemoji from "twemoji";
@ -50,7 +50,7 @@ export const JumboCmd = utilityCmd({
const emojiRegex = new RegExp(`(<.*:).*:(\\d+)`); const emojiRegex = new RegExp(`(<.*:).*:(\\d+)`);
const results = emojiRegex.exec(args.emoji); const results = emojiRegex.exec(args.emoji);
let extension = ".png"; let extension = ".png";
let file: MessageAttachment | undefined; let file: AttachmentBuilder | undefined;
if (!isEmoji(args.emoji)) { if (!isEmoji(args.emoji)) {
sendErrorMessage(pluginData, msg.channel, "Invalid emoji"); sendErrorMessage(pluginData, msg.channel, "Invalid emoji");
@ -65,10 +65,10 @@ export const JumboCmd = utilityCmd({
url += `${results[2]}${extension}`; url += `${results[2]}${extension}`;
if (extension === ".png") { if (extension === ".png") {
const image = resizeBuffer(await getBufferFromUrl(url), size, size); const image = resizeBuffer(await getBufferFromUrl(url), size, size);
file = new MessageAttachment(image, `emoji${extension}`); file = new AttachmentBuilder(image, { name: `emoji${extension}` });
} else { } else {
const image = await getBufferFromUrl(url); const image = await getBufferFromUrl(url);
file = new MessageAttachment(image, `emoji${extension}`); file = new AttachmentBuilder(image, { name: `emoji${extension}` });
} }
} else { } else {
let url = `${twemoji.base}${twemoji.size}/${twemoji.convert.toCodePoint(args.emoji)}${twemoji.ext}`; let url = `${twemoji.base}${twemoji.size}/${twemoji.convert.toCodePoint(args.emoji)}${twemoji.ext}`;
@ -87,7 +87,7 @@ export const JumboCmd = utilityCmd({
return; return;
} }
file = new MessageAttachment(image, "emoji.png"); file = new AttachmentBuilder(image, { name: "emoji.png" });
} }
msg.channel.send({ files: [file] }); msg.channel.send({ files: [file] });

View file

@ -1,8 +1,8 @@
import { Util } from "discord.js";
import { commandTypeHelpers as ct } from "../../../commandTypes"; import { commandTypeHelpers as ct } from "../../../commandTypes";
import { errorMessage } from "../../../utils"; import { errorMessage } from "../../../utils";
import { canActOn, sendSuccessMessage } from "../../../pluginUtils"; import { canActOn, sendSuccessMessage } from "../../../pluginUtils";
import { utilityCmd } from "../types"; import { utilityCmd } from "../types";
import { escapeBold } from "discord.js";
export const NicknameCmd = utilityCmd({ export const NicknameCmd = utilityCmd({
trigger: ["nickname", "nick"], trigger: ["nickname", "nick"],
@ -20,7 +20,7 @@ export const NicknameCmd = utilityCmd({
if (!args.member.nickname) { if (!args.member.nickname) {
msg.channel.send(`<@!${args.member.id}> does not have a nickname`); msg.channel.send(`<@!${args.member.id}> does not have a nickname`);
} else { } else {
msg.channel.send(`The nickname of <@!${args.member.id}> is **${Util.escapeBold(args.member.nickname)}**`); msg.channel.send(`The nickname of <@!${args.member.id}> is **${escapeBold(args.member.nickname)}**`);
} }
return; return;
} }

View file

@ -4,6 +4,7 @@ import {
Constants, Constants,
DiscordAPIError, DiscordAPIError,
Emoji, Emoji,
escapeCodeBlock,
Guild, Guild,
GuildAuditLogs, GuildAuditLogs,
GuildAuditLogsEntry, GuildAuditLogsEntry,
@ -15,7 +16,6 @@ import {
InviteGuild, InviteGuild,
LimitedCollection, LimitedCollection,
Message, Message,
MessageAttachment,
MessageEmbed, MessageEmbed,
MessageEmbedOptions, MessageEmbedOptions,
MessageMentionOptions, MessageMentionOptions,
@ -27,7 +27,6 @@ import {
TextChannel, TextChannel,
ThreadChannel, ThreadChannel,
User, User,
Util,
} from "discord.js"; } from "discord.js";
import emojiRegex from "emoji-regex"; import emojiRegex from "emoji-regex";
import { either } from "fp-ts/lib/Either"; import { either } from "fp-ts/lib/Either";
@ -258,7 +257,7 @@ export function nonNullish<V>(v: V): v is NonNullable<V> {
export type GuildInvite = Invite & { guild: InviteGuild | Guild }; export type GuildInvite = Invite & { guild: InviteGuild | Guild };
export type GroupDMInvite = Invite & { export type GroupDMInvite = Invite & {
channel: PartialChannelData; channel: PartialChannelData;
type: typeof Constants.ChannelTypes.GROUP_DM; type: typeof ChannelType.GroupDM;
}; };
/** /**
@ -648,7 +647,7 @@ interface MatchedURL extends URL {
} }
export function getUrlsInString(str: string, onlyUnique = false): MatchedURL[] { export function getUrlsInString(str: string, onlyUnique = false): MatchedURL[] {
let matches = str.match(urlRegex) || []; let matches = [...str.match(urlRegex)];
if (onlyUnique) { if (onlyUnique) {
matches = unique(matches); matches = unique(matches);
} }
@ -1409,11 +1408,11 @@ export async function confirm(channel: TextChannel, userId: string, content: Mes
export function messageSummary(msg: SavedMessage) { export function messageSummary(msg: SavedMessage) {
// Regular text content // Regular text content
let result = "```\n" + (msg.data.content ? Util.escapeCodeBlock(msg.data.content) : "<no text content>") + "```"; let result = "```\n" + (msg.data.content ? escapeCodeBlock(msg.data.content) : "<no text content>") + "```";
// Rich embed // Rich embed
const richEmbed = (msg.data.embeds || []).find((e) => (e as MessageEmbed).type === "rich"); const richEmbed = (msg.data.embeds || []).find((e) => (e as MessageEmbed).type === "rich");
if (richEmbed) result += "Embed:```" + Util.escapeCodeBlock(JSON.stringify(richEmbed)) + "```"; if (richEmbed) result += "Embed:```" + escapeCodeBlock(JSON.stringify(richEmbed)) + "```";
// Attachments // Attachments
if (msg.data.attachments && msg.data.attachments.length) { if (msg.data.attachments && msg.data.attachments.length) {