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 | |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame] | 22 | const { log, 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); |
TheCodedProf | ad0b820 | 2023-02-14 14:27:09 -0500 | [diff] [blame] | 28 | if(config.filters.clean.channels.includes(message.channel.id)) { |
| 29 | let memberRoles = message.member!.roles.cache.map(role => role.id); |
| 30 | let roleAllow = config.filters.clean.allowed.roles.some(role => memberRoles.includes(role)); |
| 31 | let userAllow = config.filters.clean.allowed.user.includes(message.author.id); |
| 32 | if(!roleAllow && !userAllow) return await message.delete(); |
| 33 | } |
TheCodedProf | baee2c1 | 2023-02-18 16:11:06 -0500 | [diff] [blame] | 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)), |
| 48 | deleted: entry(new Date().getTime(), renderDelta(new Date().getTime())), |
| 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", |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 71 | timestamp: new Date().getTime() |
| 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; |
TheCodedProf | 1611367 | 2023-02-03 16:05:23 -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", |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 108 | timestamp: new Date().getTime() |
| 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", |
| 143 | timestamp: new Date().getTime() |
| 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", |
| 173 | timestamp: new Date().getTime() |
| 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", |
| 204 | timestamp: new Date().getTime() |
| 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", |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 236 | timestamp: new Date().getTime() |
| 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", |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 268 | timestamp: new Date().getTime() |
| 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) { |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 286 | const data = { |
pineafan | e23c4ec | 2022-07-27 21:56:27 +0100 | [diff] [blame] | 287 | meta: { |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 288 | type: "everyonePing", |
| 289 | displayName: "Everyone Pinged", |
| 290 | calculateType: "messageMassPing", |
pineafan | e23c4ec | 2022-07-27 21:56:27 +0100 | [diff] [blame] | 291 | color: NucleusColors.yellow, |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 292 | emoji: "MESSAGE.PING.EVERYONE", |
pineafan | e23c4ec | 2022-07-27 21:56:27 +0100 | [diff] [blame] | 293 | timestamp: new Date().getTime() |
| 294 | }, |
| 295 | separate: { |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame] | 296 | start: content ? `**Message:**\n\`\`\`${content}\`\`\`` : "**Message:** *Message had no content*" |
pineafan | e23c4ec | 2022-07-27 21:56:27 +0100 | [diff] [blame] | 297 | }, |
| 298 | list: list, |
| 299 | hidden: { |
| 300 | guild: message.channel.guild.id |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 301 | } |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 302 | }; |
pineafan | e23c4ec | 2022-07-27 21:56:27 +0100 | [diff] [blame] | 303 | return log(data); |
| 304 | } |
| 305 | if (config.filters.pings.roles) { |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 306 | for (const roleId in message.mentions.roles) { |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 307 | if (!config.filters.pings.allowed.roles.includes(roleId)) { |
PineaFan | 0d06edc | 2023-01-17 22:10:31 +0000 | [diff] [blame] | 308 | messageException(message.guild.id, message.channel.id, message.id); |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 309 | await message.delete(); |
| 310 | const data = { |
pineafan | e23c4ec | 2022-07-27 21:56:27 +0100 | [diff] [blame] | 311 | meta: { |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 312 | type: "rolePing", |
| 313 | displayName: "Role Pinged", |
| 314 | calculateType: "messageMassPing", |
pineafan | e23c4ec | 2022-07-27 21:56:27 +0100 | [diff] [blame] | 315 | color: NucleusColors.yellow, |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 316 | emoji: "MESSAGE.PING.ROLE", |
pineafan | e23c4ec | 2022-07-27 21:56:27 +0100 | [diff] [blame] | 317 | timestamp: new Date().getTime() |
| 318 | }, |
| 319 | separate: { |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 320 | start: content |
| 321 | ? `**Message:**\n\`\`\`${content}\`\`\`` |
| 322 | : "**Message:** *Message had no content*" |
pineafan | e23c4ec | 2022-07-27 21:56:27 +0100 | [diff] [blame] | 323 | }, |
| 324 | list: list, |
| 325 | hidden: { |
| 326 | guild: message.channel.guild.id |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 327 | } |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 328 | }; |
pineafan | e23c4ec | 2022-07-27 21:56:27 +0100 | [diff] [blame] | 329 | return log(data); |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 330 | } |
| 331 | } |
pineafan | e23c4ec | 2022-07-27 21:56:27 +0100 | [diff] [blame] | 332 | } |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame] | 333 | if (message.mentions.users.size >= config.filters.pings.mass && config.filters.pings.mass) { |
PineaFan | 0d06edc | 2023-01-17 22:10:31 +0000 | [diff] [blame] | 334 | messageException(message.guild.id, message.channel.id, message.id); |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 335 | await message.delete(); |
| 336 | const data = { |
pineafan | e23c4ec | 2022-07-27 21:56:27 +0100 | [diff] [blame] | 337 | meta: { |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 338 | type: "massPing", |
| 339 | displayName: "Mass Ping", |
| 340 | calculateType: "messageMassPing", |
pineafan | e23c4ec | 2022-07-27 21:56:27 +0100 | [diff] [blame] | 341 | color: NucleusColors.yellow, |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 342 | emoji: "MESSAGE.PING.MASS", |
pineafan | e23c4ec | 2022-07-27 21:56:27 +0100 | [diff] [blame] | 343 | timestamp: new Date().getTime() |
| 344 | }, |
| 345 | separate: { |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame] | 346 | start: content ? `**Message:**\n\`\`\`${content}\`\`\`` : "**Message:** *Message had no content*" |
pineafan | e23c4ec | 2022-07-27 21:56:27 +0100 | [diff] [blame] | 347 | }, |
| 348 | list: list, |
| 349 | hidden: { |
| 350 | guild: message.channel.guild.id |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 351 | } |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 352 | }; |
pineafan | e23c4ec | 2022-07-27 21:56:27 +0100 | [diff] [blame] | 353 | return log(data); |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 354 | } |
| 355 | } |