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