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