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