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