diff options
author | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2022-08-05 23:24:51 -0400 |
---|---|---|
committer | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2022-08-05 23:24:51 -0400 |
commit | 1feb515882cfbbf33dc98d75a54898c1735cf5cb (patch) | |
tree | 20386e9d6ca6b5cb978283d672528c03647ec32f /src/lib/extensions/discord.js/ExtendedGuild.ts | |
parent | e68a0193b9f5888455f631d72c8783fc50e35faf (diff) | |
parent | 060349fcabe9e073eca9f6fd334e3355a9756096 (diff) | |
download | tanzanite-1feb515882cfbbf33dc98d75a54898c1735cf5cb.tar.gz tanzanite-1feb515882cfbbf33dc98d75a54898c1735cf5cb.tar.bz2 tanzanite-1feb515882cfbbf33dc98d75a54898c1735cf5cb.zip |
Merge branch 'wip'
Diffstat (limited to 'src/lib/extensions/discord.js/ExtendedGuild.ts')
-rw-r--r-- | src/lib/extensions/discord.js/ExtendedGuild.ts | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/src/lib/extensions/discord.js/ExtendedGuild.ts b/src/lib/extensions/discord.js/ExtendedGuild.ts index c58916c..88bf5f1 100644 --- a/src/lib/extensions/discord.js/ExtendedGuild.ts +++ b/src/lib/extensions/discord.js/ExtendedGuild.ts @@ -11,6 +11,7 @@ import { type GuildLogType, type GuildModel } from '#lib'; +import assert from 'assert/strict'; import { AttachmentBuilder, AttachmentPayload, @@ -735,10 +736,33 @@ export class ExtendedGuild extends Guild { sendOptions.content = 'Wondering who to invite? Start by inviting anyone who can help you build the server!'; break; + // todo: use enum for this + case 24 as MessageType: { + const embed = quote.embeds[0]; + assert.equal(embed.data.type, 'auto_moderation_message'); + const ruleName = embed.fields!.find((f) => f.name === 'rule_name')!.value; + const channelId = embed.fields!.find((f) => f.name === 'channel_id')!.value; + const keyword = embed.fields!.find((f) => f.name === 'keyword')!.value; + + sendOptions.username = `AutoMod (${quote.member?.displayName ?? quote.author.username})`; + sendOptions.content = `Automod has blocked a message in <#${channelId}>`; + sendOptions.embeds = [ + { + title: quote.member?.displayName ?? quote.author.username, + description: embed.description ?? 'There is no content???', + footer: { + text: `Keyword: ${keyword} • Rule: ${ruleName}` + }, + color: 0x36393f + } + ]; + + break; + } case MessageType.ChannelIconChange: case MessageType.Call: default: - sendOptions.content = `${emojis.error} I cannot quote **${ + sendOptions.content = `${emojis.error} I cannot quote messages of type **${ MessageType[quote.type] || quote.type }** messages, please report this to my developers.`; @@ -746,7 +770,7 @@ export class ExtendedGuild extends Guild { } sendOptions.allowedMentions = AllowedMentions.none(); - sendOptions.username = quote.member?.displayName ?? quote.author.username; + sendOptions.username ??= quote.member?.displayName ?? quote.author.username; sendOptions.avatarURL = quote.member?.displayAvatarURL({ size: 2048 }) ?? quote.author.displayAvatarURL({ size: 2048 }); return await webhook.send(sendOptions); /* .catch((e: any) => e); */ |