diff options
| author | Fuwn <[email protected]> | 2025-11-07 23:22:43 -0800 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2025-11-07 23:22:43 -0800 |
| commit | 8f1d7e4f7d5927659029a040b929e0d9060fd989 (patch) | |
| tree | d55ec59271a03395bca2c16255afb0138f9267a9 | |
| parent | feat(gateway:memberLeave): Log leaving users (diff) | |
| download | umabotdiscord-8f1d7e4f7d5927659029a040b929e0d9060fd989.tar.xz umabotdiscord-8f1d7e4f7d5927659029a040b929e0d9060fd989.zip | |
feat(gateway:imageDeletion): Add allowed roles
| -rw-r--r-- | packages/gateway/src/listeners/imageDeletion.ts | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/packages/gateway/src/listeners/imageDeletion.ts b/packages/gateway/src/listeners/imageDeletion.ts index 0a30c2c..f004a6b 100644 --- a/packages/gateway/src/listeners/imageDeletion.ts +++ b/packages/gateway/src/listeners/imageDeletion.ts @@ -1,8 +1,19 @@ import { Client, Events, Message } from "discord.js"; import { logUnexpectedDiscordAPIError } from "../utilities"; +import { + CENTRAL_ADMINISTRATOR_ROLE_ID, + CENTRAL_MODERATOR_ROLE_ID, + CENTRAL_OWNER_ROLE_ID, +} from "../constants"; const NSFW_TEXT_CHANNEL_ID = "1436346138478383174"; +const ALLOWED_ROLES = [ + CENTRAL_OWNER_ROLE_ID, + CENTRAL_ADMINISTRATOR_ROLE_ID, + CENTRAL_MODERATOR_ROLE_ID, +] as const; + const isGif = (filename: string): boolean => { return filename.toLowerCase().endsWith(".gif"); }; @@ -25,6 +36,14 @@ export const handleImageDeletion = (client: Client) => { if (message.attachments.size === 0) return; + if (message.member) { + const hasAllowedRole = ALLOWED_ROLES.some((roleId) => + message.member!.roles.cache.has(roleId), + ); + + if (hasAllowedRole) return; + } + const allAttachments = Array.from(message.attachments.values()); const hasGif = allAttachments.some((attachment) => isGif(attachment.name)); |