PineaFan | 752af46 | 2022-12-31 21:59:38 +0000 | [diff] [blame] | 1 | import type { NucleusClient } from "../utils/client.js"; |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame] | 2 | import { LinkCheck, MalwareCheck, NSFWCheck, SizeCheck, TestString, TestImage } from "../reflex/scanners.js"; |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 3 | import logAttachment from "../premium/attachmentLogs.js"; |
PineaFan | 0d06edc | 2023-01-17 22:10:31 +0000 | [diff] [blame] | 4 | import { messageException } from "../utils/createTemporaryStorage.js"; |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 5 | import getEmojiByName from "../utils/getEmojiByName.js"; |
| 6 | import client from "../utils/client.js"; |
pineafan | 0f5cc78 | 2022-08-12 21:55:42 +0100 | [diff] [blame] | 7 | import { callback as statsChannelUpdate } from "../reflex/statsChannelUpdate.js"; |
Skyler Grey | 3331c9f | 2023-03-05 07:34:15 +0000 | [diff] [blame] | 8 | import { ChannelType, Message, ThreadChannel } from "discord.js"; |
TheCodedProf | b7a7b99 | 2023-03-05 16:11:59 -0500 | [diff] [blame] | 9 | import singleNotify from "../utils/singleNotify.js"; |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 10 | |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 11 | export const event = "messageCreate"; |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 12 | |
PineaFan | 752af46 | 2022-12-31 21:59:38 +0000 | [diff] [blame] | 13 | export async function callback(_client: NucleusClient, message: Message) { |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 14 | if (!message.guild) return; |
PineappleFan | 13892c6 | 2023-03-05 07:00:07 +0000 | [diff] [blame] | 15 | const config = await client.memory.readGuildInfo(message.guild.id); |
Skyler | 9f5fca8 | 2023-03-05 09:12:03 +0000 | [diff] [blame] | 16 | |
Skyler Grey | da16adf | 2023-03-05 10:22:12 +0000 | [diff] [blame] | 17 | if ( |
| 18 | config.autoPublish.enabled && |
| 19 | config.autoPublish.channels.includes(message.channel.id) && |
| 20 | message.channel.type === ChannelType.GuildAnnouncement && |
| 21 | message.reference === null |
Skyler | 9f5fca8 | 2023-03-05 09:12:03 +0000 | [diff] [blame] | 22 | ) { |
TheCodedProf | b7a7b99 | 2023-03-05 16:11:59 -0500 | [diff] [blame] | 23 | if(message.channel.permissionsFor(message.guild.members.me!)!.has("ManageMessages")) { |
| 24 | await message.crosspost(); |
| 25 | } else { |
| 26 | singleNotify(`I don't have permissions to publish in <#${message.channel.id}>`, message.guild.id, true); |
| 27 | } |
PineappleFan | 13892c6 | 2023-03-05 07:00:07 +0000 | [diff] [blame] | 28 | } |
| 29 | |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 30 | if (message.author.bot) return; |
PineaFan | 538d375 | 2023-01-12 21:48:23 +0000 | [diff] [blame] | 31 | if (message.channel.isDMBased()) return; |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 32 | try { |
pineafan | 0f5cc78 | 2022-08-12 21:55:42 +0100 | [diff] [blame] | 33 | await statsChannelUpdate(client, await message.guild.members.fetch(message.author.id)); |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 34 | } catch (e) { |
| 35 | console.log(e); |
| 36 | } |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 37 | |
TheCodedProf | 6ec331b | 2023-02-20 12:13:06 -0500 | [diff] [blame] | 38 | const { log, isLogging, NucleusColors, entry, renderUser, renderDelta, renderChannel } = client.logger; |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 39 | |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 40 | const fileNames = await logAttachment(message); |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 41 | |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 42 | const content = message.content.toLowerCase() || ""; |
Skyler Grey | da16adf | 2023-03-05 10:22:12 +0000 | [diff] [blame] | 43 | if (config.filters.clean.channels.includes(message.channel.id)) { |
| 44 | const memberRoles = message.member!.roles.cache.map((role) => role.id); |
| 45 | const roleAllow = config.filters.clean.allowed.roles.some((role) => memberRoles.includes(role)); |
TheCodedProf | f8ef794 | 2023-03-03 15:32:32 -0500 | [diff] [blame] | 46 | const userAllow = config.filters.clean.allowed.users.includes(message.author.id); |
Skyler Grey | da16adf | 2023-03-05 10:22:12 +0000 | [diff] [blame] | 47 | if (!roleAllow && !userAllow) return await message.delete(); |
TheCodedProf | ad0b820 | 2023-02-14 14:27:09 -0500 | [diff] [blame] | 48 | } |
TheCodedProf | baee2c1 | 2023-02-18 16:11:06 -0500 | [diff] [blame] | 49 | |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 50 | const filter = getEmojiByName("ICONS.FILTER"); |
| 51 | let attachmentJump = ""; |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 52 | if (config.logging.attachments.saved[message.channel.id + message.id]) { |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame] | 53 | attachmentJump = ` [[View attachments]](${config.logging.attachments.saved[message.channel.id + message.id]})`; |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 54 | } |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 55 | const list = { |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 56 | messageId: entry(message.id, `\`${message.id}\``), |
| 57 | sentBy: entry(message.author.id, renderUser(message.author)), |
| 58 | sentIn: entry(message.channel.id, renderChannel(message.channel)), |
TheCodedProf | 6ec331b | 2023-02-20 12:13:06 -0500 | [diff] [blame] | 59 | deleted: entry(Date.now(), renderDelta(Date.now())), |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 60 | mentions: message.mentions.users.size, |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame] | 61 | attachments: entry(message.attachments.size, message.attachments.size + attachmentJump), |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 62 | repliedTo: entry( |
PineaFan | 538d375 | 2023-01-12 21:48:23 +0000 | [diff] [blame] | 63 | (message.reference ? message.reference.messageId : null) ?? null, |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 64 | message.reference |
| 65 | ? `[[Jump to message]](https://discord.com/channels/${message.guild.id}/${message.channel.id}/${message.reference.messageId})` |
| 66 | : "None" |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 67 | ) |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 68 | }; |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 69 | |
| 70 | if (config.filters.invite.enabled) { |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame] | 71 | if (!config.filters.invite.allowed.channels.includes(message.channel.id)) { |
| 72 | if (/(?:https?:\/\/)?discord(?:app)?\.(?:com\/invite|gg)\/[a-zA-Z0-9]+\/?/.test(content)) { |
PineaFan | 0d06edc | 2023-01-17 22:10:31 +0000 | [diff] [blame] | 73 | messageException(message.guild.id, message.channel.id, message.id); |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 74 | message.delete(); |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 75 | const data = { |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 76 | meta: { |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 77 | type: "messageDelete", |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame] | 78 | displayName: "Message Deleted (Automated, Contained Invite)", |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 79 | calculateType: "autoModeratorDeleted", |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 80 | color: NucleusColors.red, |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 81 | emoji: "MESSAGE.DELETE", |
TheCodedProf | 6ec331b | 2023-02-20 12:13:06 -0500 | [diff] [blame] | 82 | timestamp: Date.now() |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 83 | }, |
| 84 | separate: { |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 85 | start: |
| 86 | filter + |
| 87 | " Contained invite\n\n" + |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame] | 88 | (content ? `**Message:**\n\`\`\`${content}\`\`\`` : "**Message:** *Message had no content*") |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 89 | }, |
| 90 | list: list, |
| 91 | hidden: { |
| 92 | guild: message.channel.guild.id |
| 93 | } |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 94 | }; |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 95 | return log(data); |
| 96 | } |
| 97 | } |
| 98 | } |
| 99 | |
| 100 | if (fileNames.files.length > 0) { |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 101 | for (const element of fileNames.files) { |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 102 | const url = element.url ? element.url : element.local; |
Skyler Grey | da16adf | 2023-03-05 10:22:12 +0000 | [diff] [blame] | 103 | if ( |
| 104 | /\.(j(pe?g|fif)|a?png|gifv?|w(eb[mp]|av)|mp([34]|eg-\d)|ogg|avi|h\.26(4|5)|cda)$/.test( |
| 105 | url.toLowerCase() |
| 106 | ) |
| 107 | ) { |
TheCodedProf | 1611367 | 2023-02-03 16:05:23 -0500 | [diff] [blame] | 108 | // jpg|jpeg|png|apng|gif|gifv|webm|webp|mp4|wav|mp3|ogg|jfif|MPEG-#|avi|h.264|h.265 |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 109 | if ( |
Skyler Grey | c634e2b | 2022-08-06 17:50:48 +0100 | [diff] [blame] | 110 | config.filters.images.NSFW && |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame] | 111 | !(message.channel instanceof ThreadChannel ? message.channel.parent?.nsfw : message.channel.nsfw) |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 112 | ) { |
Skyler Grey | c634e2b | 2022-08-06 17:50:48 +0100 | [diff] [blame] | 113 | if (await NSFWCheck(url)) { |
PineaFan | 0d06edc | 2023-01-17 22:10:31 +0000 | [diff] [blame] | 114 | messageException(message.guild.id, message.channel.id, message.id); |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 115 | await message.delete(); |
| 116 | const data = { |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 117 | meta: { |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 118 | type: "messageDelete", |
| 119 | displayName: "Message Deleted", |
| 120 | calculateType: "autoModeratorDeleted", |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 121 | color: NucleusColors.red, |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 122 | emoji: "MESSAGE.DELETE", |
TheCodedProf | 6ec331b | 2023-02-20 12:13:06 -0500 | [diff] [blame] | 123 | timestamp: Date.now() |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 124 | }, |
| 125 | separate: { |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 126 | start: |
| 127 | filter + |
Skyler Grey | c634e2b | 2022-08-06 17:50:48 +0100 | [diff] [blame] | 128 | " Image detected as NSFW\n\n" + |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 129 | (content |
| 130 | ? `**Message:**\n\`\`\`${content}\`\`\`` |
| 131 | : "**Message:** *Message had no content*") |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 132 | }, |
| 133 | list: list, |
| 134 | hidden: { |
| 135 | guild: message.channel.guild.id |
| 136 | } |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 137 | }; |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 138 | return log(data); |
| 139 | } |
| 140 | } |
Skyler Grey | c634e2b | 2022-08-06 17:50:48 +0100 | [diff] [blame] | 141 | if (config.filters.wordFilter.enabled) { |
| 142 | const text = await TestImage(url); |
| 143 | const check = TestString( |
| 144 | text ?? "", |
| 145 | config.filters.wordFilter.words.loose, |
| 146 | config.filters.wordFilter.words.strict |
| 147 | ); |
| 148 | if (check !== null) { |
PineaFan | 0d06edc | 2023-01-17 22:10:31 +0000 | [diff] [blame] | 149 | messageException(message.guild.id, message.channel.id, message.id); |
Skyler Grey | c634e2b | 2022-08-06 17:50:48 +0100 | [diff] [blame] | 150 | await message.delete(); |
| 151 | const data = { |
| 152 | meta: { |
| 153 | type: "messageDelete", |
| 154 | displayName: "Message Deleted", |
| 155 | calculateType: "autoModeratorDeleted", |
| 156 | color: NucleusColors.red, |
| 157 | emoji: "MESSAGE.DELETE", |
TheCodedProf | 6ec331b | 2023-02-20 12:13:06 -0500 | [diff] [blame] | 158 | timestamp: Date.now() |
Skyler Grey | c634e2b | 2022-08-06 17:50:48 +0100 | [diff] [blame] | 159 | }, |
| 160 | separate: { |
| 161 | start: |
| 162 | filter + |
| 163 | " Image contained filtered word\n\n" + |
| 164 | (content |
| 165 | ? `**Message:**\n\`\`\`${content}\`\`\`` |
| 166 | : "**Message:** *Message had no content*") |
| 167 | }, |
| 168 | list: list, |
| 169 | hidden: { |
| 170 | guild: message.channel.guild.id |
| 171 | } |
| 172 | }; |
| 173 | return log(data); |
| 174 | } |
| 175 | } |
| 176 | if (config.filters.images.size) { |
| 177 | if (url.match(/\.+(webp|png|jpg)$/gi)) { |
| 178 | if (!(await SizeCheck(element))) { |
PineaFan | 0d06edc | 2023-01-17 22:10:31 +0000 | [diff] [blame] | 179 | messageException(message.guild.id, message.channel.id, message.id); |
Skyler Grey | c634e2b | 2022-08-06 17:50:48 +0100 | [diff] [blame] | 180 | await message.delete(); |
| 181 | const data = { |
| 182 | meta: { |
| 183 | type: "messageDelete", |
| 184 | displayName: "Message Deleted", |
| 185 | calculateType: "autoModeratorDeleted", |
| 186 | color: NucleusColors.red, |
| 187 | emoji: "MESSAGE.DELETE", |
TheCodedProf | 6ec331b | 2023-02-20 12:13:06 -0500 | [diff] [blame] | 188 | timestamp: Date.now() |
Skyler Grey | c634e2b | 2022-08-06 17:50:48 +0100 | [diff] [blame] | 189 | }, |
| 190 | separate: { |
| 191 | start: |
| 192 | filter + |
| 193 | " Image was too small\n\n" + |
| 194 | (content |
| 195 | ? `**Message:**\n\`\`\`${content}\`\`\`` |
| 196 | : "**Message:** *Message had no content*") |
| 197 | }, |
| 198 | list: list, |
| 199 | hidden: { |
| 200 | guild: message.channel.guild.id |
| 201 | } |
| 202 | }; |
| 203 | return log(data); |
| 204 | } |
| 205 | } |
| 206 | } |
| 207 | } |
| 208 | if (config.filters.malware) { |
| 209 | if (!(await MalwareCheck(url))) { |
PineaFan | 0d06edc | 2023-01-17 22:10:31 +0000 | [diff] [blame] | 210 | messageException(message.guild.id, message.channel.id, message.id); |
Skyler Grey | c634e2b | 2022-08-06 17:50:48 +0100 | [diff] [blame] | 211 | await message.delete(); |
| 212 | const data = { |
| 213 | meta: { |
| 214 | type: "messageDelete", |
| 215 | displayName: "Message Deleted", |
| 216 | calculateType: "autoModeratorDeleted", |
| 217 | color: NucleusColors.red, |
| 218 | emoji: "MESSAGE.DELETE", |
TheCodedProf | 6ec331b | 2023-02-20 12:13:06 -0500 | [diff] [blame] | 219 | timestamp: Date.now() |
Skyler Grey | c634e2b | 2022-08-06 17:50:48 +0100 | [diff] [blame] | 220 | }, |
| 221 | separate: { |
| 222 | start: |
| 223 | filter + |
| 224 | " File detected as malware\n\n" + |
| 225 | (content |
| 226 | ? `**Message:**\n\`\`\`${content}\`\`\`` |
| 227 | : "**Message:** *Message had no content*") |
| 228 | }, |
| 229 | list: list, |
| 230 | hidden: { |
| 231 | guild: message.channel.guild.id |
| 232 | } |
| 233 | }; |
| 234 | return log(data); |
| 235 | } |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 236 | } |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 237 | } |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 238 | } |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 239 | |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 240 | const linkDetectionTypes = await LinkCheck(message); |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 241 | if (linkDetectionTypes.length > 0) { |
PineaFan | 0d06edc | 2023-01-17 22:10:31 +0000 | [diff] [blame] | 242 | messageException(message.guild.id, message.channel.id, message.id); |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 243 | await message.delete(); |
| 244 | const data = { |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 245 | meta: { |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 246 | type: "messageDelete", |
| 247 | displayName: "Message Deleted", |
| 248 | calculateType: "autoModeratorDeleted", |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 249 | color: NucleusColors.red, |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 250 | emoji: "MESSAGE.DELETE", |
TheCodedProf | 6ec331b | 2023-02-20 12:13:06 -0500 | [diff] [blame] | 251 | timestamp: Date.now() |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 252 | }, |
| 253 | separate: { |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 254 | start: |
| 255 | filter + |
| 256 | ` Link filtered as ${linkDetectionTypes[0]?.toLowerCase()}\n\n` + |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame] | 257 | (content ? `**Message:**\n\`\`\`${content}\`\`\`` : "**Message:** *Message had no content*") |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 258 | }, |
| 259 | list: list, |
| 260 | hidden: { |
| 261 | guild: message.channel.guild.id |
| 262 | } |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 263 | }; |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 264 | return log(data); |
| 265 | } |
pineafan | e23c4ec | 2022-07-27 21:56:27 +0100 | [diff] [blame] | 266 | |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 267 | if (config.filters.wordFilter.enabled) { |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 268 | const check = TestString( |
| 269 | content, |
| 270 | config.filters.wordFilter.words.loose, |
| 271 | config.filters.wordFilter.words.strict |
| 272 | ); |
| 273 | if (check !== null) { |
PineaFan | 0d06edc | 2023-01-17 22:10:31 +0000 | [diff] [blame] | 274 | messageException(message.guild.id, message.channel.id, message.id); |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 275 | await message.delete(); |
| 276 | const data = { |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 277 | meta: { |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 278 | type: "messageDelete", |
| 279 | displayName: "Message Deleted", |
| 280 | calculateType: "autoModeratorDeleted", |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 281 | color: NucleusColors.red, |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 282 | emoji: "MESSAGE.DELETE", |
TheCodedProf | 6ec331b | 2023-02-20 12:13:06 -0500 | [diff] [blame] | 283 | timestamp: Date.now() |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 284 | }, |
| 285 | separate: { |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 286 | start: |
| 287 | filter + |
| 288 | " Message contained filtered word\n\n" + |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame] | 289 | (content ? `**Message:**\n\`\`\`${content}\`\`\`` : "**Message:** *Message had no content*") |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 290 | }, |
| 291 | list: list, |
| 292 | hidden: { |
| 293 | guild: message.channel.guild.id |
| 294 | } |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 295 | }; |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 296 | return log(data); |
| 297 | } |
| 298 | } |
| 299 | |
pineafan | e23c4ec | 2022-07-27 21:56:27 +0100 | [diff] [blame] | 300 | if (config.filters.pings.everyone && message.mentions.everyone) { |
Skyler Grey | da16adf | 2023-03-05 10:22:12 +0000 | [diff] [blame] | 301 | if (!(await isLogging(message.guild.id, "messageMassPing"))) return; |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 302 | const data = { |
pineafan | e23c4ec | 2022-07-27 21:56:27 +0100 | [diff] [blame] | 303 | meta: { |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 304 | type: "everyonePing", |
| 305 | displayName: "Everyone Pinged", |
| 306 | calculateType: "messageMassPing", |
pineafan | e23c4ec | 2022-07-27 21:56:27 +0100 | [diff] [blame] | 307 | color: NucleusColors.yellow, |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 308 | emoji: "MESSAGE.PING.EVERYONE", |
TheCodedProf | 6ec331b | 2023-02-20 12:13:06 -0500 | [diff] [blame] | 309 | timestamp: Date.now() |
pineafan | e23c4ec | 2022-07-27 21:56:27 +0100 | [diff] [blame] | 310 | }, |
| 311 | separate: { |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame] | 312 | start: content ? `**Message:**\n\`\`\`${content}\`\`\`` : "**Message:** *Message had no content*" |
pineafan | e23c4ec | 2022-07-27 21:56:27 +0100 | [diff] [blame] | 313 | }, |
| 314 | list: list, |
| 315 | hidden: { |
| 316 | guild: message.channel.guild.id |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 317 | } |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 318 | }; |
pineafan | e23c4ec | 2022-07-27 21:56:27 +0100 | [diff] [blame] | 319 | return log(data); |
| 320 | } |
| 321 | if (config.filters.pings.roles) { |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 322 | for (const roleId in message.mentions.roles) { |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 323 | if (!config.filters.pings.allowed.roles.includes(roleId)) { |
PineaFan | 0d06edc | 2023-01-17 22:10:31 +0000 | [diff] [blame] | 324 | messageException(message.guild.id, message.channel.id, message.id); |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 325 | await message.delete(); |
Skyler Grey | da16adf | 2023-03-05 10:22:12 +0000 | [diff] [blame] | 326 | if (!(await isLogging(message.guild.id, "messageMassPing"))) return; |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 327 | const data = { |
pineafan | e23c4ec | 2022-07-27 21:56:27 +0100 | [diff] [blame] | 328 | meta: { |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 329 | type: "rolePing", |
| 330 | displayName: "Role Pinged", |
| 331 | calculateType: "messageMassPing", |
pineafan | e23c4ec | 2022-07-27 21:56:27 +0100 | [diff] [blame] | 332 | color: NucleusColors.yellow, |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 333 | emoji: "MESSAGE.PING.ROLE", |
TheCodedProf | 6ec331b | 2023-02-20 12:13:06 -0500 | [diff] [blame] | 334 | timestamp: Date.now() |
pineafan | e23c4ec | 2022-07-27 21:56:27 +0100 | [diff] [blame] | 335 | }, |
| 336 | separate: { |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 337 | start: content |
| 338 | ? `**Message:**\n\`\`\`${content}\`\`\`` |
| 339 | : "**Message:** *Message had no content*" |
pineafan | e23c4ec | 2022-07-27 21:56:27 +0100 | [diff] [blame] | 340 | }, |
| 341 | list: list, |
| 342 | hidden: { |
| 343 | guild: message.channel.guild.id |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 344 | } |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 345 | }; |
pineafan | e23c4ec | 2022-07-27 21:56:27 +0100 | [diff] [blame] | 346 | return log(data); |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 347 | } |
| 348 | } |
pineafan | e23c4ec | 2022-07-27 21:56:27 +0100 | [diff] [blame] | 349 | } |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame] | 350 | if (message.mentions.users.size >= config.filters.pings.mass && config.filters.pings.mass) { |
PineaFan | 0d06edc | 2023-01-17 22:10:31 +0000 | [diff] [blame] | 351 | messageException(message.guild.id, message.channel.id, message.id); |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 352 | await message.delete(); |
Skyler Grey | da16adf | 2023-03-05 10:22:12 +0000 | [diff] [blame] | 353 | if (!(await isLogging(message.guild.id, "messageMassPing"))) return; |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 354 | const data = { |
pineafan | e23c4ec | 2022-07-27 21:56:27 +0100 | [diff] [blame] | 355 | meta: { |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 356 | type: "massPing", |
| 357 | displayName: "Mass Ping", |
| 358 | calculateType: "messageMassPing", |
pineafan | e23c4ec | 2022-07-27 21:56:27 +0100 | [diff] [blame] | 359 | color: NucleusColors.yellow, |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 360 | emoji: "MESSAGE.PING.MASS", |
TheCodedProf | 6ec331b | 2023-02-20 12:13:06 -0500 | [diff] [blame] | 361 | timestamp: Date.now() |
pineafan | e23c4ec | 2022-07-27 21:56:27 +0100 | [diff] [blame] | 362 | }, |
| 363 | separate: { |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame] | 364 | start: content ? `**Message:**\n\`\`\`${content}\`\`\`` : "**Message:** *Message had no content*" |
pineafan | e23c4ec | 2022-07-27 21:56:27 +0100 | [diff] [blame] | 365 | }, |
| 366 | list: list, |
| 367 | hidden: { |
| 368 | guild: message.channel.guild.id |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 369 | } |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 370 | }; |
pineafan | e23c4ec | 2022-07-27 21:56:27 +0100 | [diff] [blame] | 371 | return log(data); |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 372 | } |
| 373 | } |