From 06f64139456573cc499a9e61723bc4910f5b008f Mon Sep 17 00:00:00 2001 From: Hri7566 Date: Sat, 13 Jul 2024 00:30:40 -0400 Subject: [PATCH] Add unban message --- src/ws/events/user/handlers/unban.ts | 14 ++++++++++++++ src/ws/events/user/index.ts | 2 ++ 2 files changed, 16 insertions(+) create mode 100644 src/ws/events/user/handlers/unban.ts diff --git a/src/ws/events/user/handlers/unban.ts b/src/ws/events/user/handlers/unban.ts new file mode 100644 index 0000000..5a792ad --- /dev/null +++ b/src/ws/events/user/handlers/unban.ts @@ -0,0 +1,14 @@ +import { ServerEventListener } from "../../../../util/types"; + +export const unban: ServerEventListener<"unban"> = { + id: "unban", + callback: (msg, socket) => { + // Kickbanning someone from channel + if (typeof msg._id !== "string") return; + + if (socket.rateLimits) + if (!socket.rateLimits.normal.unban.attempt()) return; + + socket.unban(msg._id); + } +}; diff --git a/src/ws/events/user/index.ts b/src/ws/events/user/index.ts index 9f257d0..116d865 100644 --- a/src/ws/events/user/index.ts +++ b/src/ws/events/user/index.ts @@ -16,6 +16,7 @@ import { chset } from "./handlers/chset"; import { kickban } from "./handlers/kickban"; import { bye } from "./handlers/bye"; import { chown } from "./handlers/chown"; +import { unban } from "./handlers/unban"; // Imagine not having an "addMany" function... @@ -45,6 +46,7 @@ EVENTGROUP_USER.addMany( admin_message, chset, kickban, + unban, bye, chown );