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