From ab769fb546806ac5bb86193e44418cecbdc8d22f Mon Sep 17 00:00:00 2001 From: qwerinope Date: Sun, 29 Jun 2025 16:52:08 +0200 Subject: [PATCH] renamed unbannableUsers to something better --- bot/commands/addadmin.ts | 2 +- bot/commands/index.ts | 2 +- bot/commands/removeadmin.ts | 6 +++--- bot/events/message.ts | 8 ++++---- bot/index.ts | 4 ++-- bot/lib/timeout.ts | 4 ++-- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/bot/commands/addadmin.ts b/bot/commands/addadmin.ts index a3a3cd3..cc0860e 100644 --- a/bot/commands/addadmin.ts +++ b/bot/commands/addadmin.ts @@ -3,7 +3,7 @@ import { addAdmin } from "../lib/admins"; import parseCommandArgs from "../lib/parseCommandArgs"; import { User } from "../user"; -export default new Command('addadmin', ['addadmin'], 'unbannable', async msg => { +export default new Command('addadmin', ['addadmin'], 'streamer', async msg => { const args = parseCommandArgs(msg.messageText); if (!args[0]) { await sendMessage('Please specify a target', msg.messageId); return; }; const target = await User.initUsername(args[0].toLowerCase()); diff --git a/bot/commands/index.ts b/bot/commands/index.ts index d30a61a..ec95ac3 100644 --- a/bot/commands/index.ts +++ b/bot/commands/index.ts @@ -1,7 +1,7 @@ import { EventSubChannelChatMessageEvent } from "@twurple/eventsub-base"; import { User } from "../user"; -export type userType = 'chatter' | 'admin' | 'unbannable'; +export type userType = 'chatter' | 'admin' | 'streamer'; /** The Command class represents a command */ export class Command { diff --git a/bot/commands/removeadmin.ts b/bot/commands/removeadmin.ts index 1bf0f59..a745db5 100644 --- a/bot/commands/removeadmin.ts +++ b/bot/commands/removeadmin.ts @@ -1,15 +1,15 @@ import { Command, sendMessage } from "."; -import { unbannableUsers } from ".."; +import { streamerUsers } from ".."; import { removeAdmin } from "../lib/admins"; import parseCommandArgs from "../lib/parseCommandArgs"; import { User } from "../user"; -export default new Command('removeadmin', ['removeadmin'], 'unbannable', async msg => { +export default new Command('removeadmin', ['removeadmin'], 'streamer', async msg => { const args = parseCommandArgs(msg.messageText); if (!args[0]) { await sendMessage('Please specify a target', msg.messageId); return; }; const target = await User.initUsername(args[0].toLowerCase()); if (!target) { await sendMessage(`Chatter ${args[0]} doesn't exist`, msg.messageId); return; }; - if (unbannableUsers.includes(target.id)) { await sendMessage(`Can't remove admin ${target.displayName} as they are managed by the bot program`, msg.messageId); return; }; + if (streamerUsers.includes(target.id)) { await sendMessage(`Can't remove admin ${target.displayName} as they are managed by the bot program`, msg.messageId); return; }; const data = await removeAdmin(target.id); if (data === 1) await sendMessage(`${target.displayName} is no longer an admin`, msg.messageId); else await sendMessage(`${target.displayName} isn't an admin`, msg.messageId); diff --git a/bot/events/message.ts b/bot/events/message.ts index e981a23..5769b1a 100644 --- a/bot/events/message.ts +++ b/bot/events/message.ts @@ -1,4 +1,4 @@ -import { chatterId, streamerId, eventSub, commandPrefix, singleUserMode, unbannableUsers } from ".."; +import { chatterId, streamerId, eventSub, commandPrefix, singleUserMode, streamerUsers } from ".."; import { User } from "../user"; import commands from "../commands"; import { redis } from "bun"; @@ -23,7 +23,7 @@ eventSub.onChannelChatMessage(streamerId, streamerId, async msg => { redis.smembers('disabledcommands') ]); - if (!unbannableUsers.includes(msg.chatterId)) user?.makeVulnerable(); // Make the user vulnerable to explosions + if (!streamerUsers.includes(msg.chatterId)) user?.makeVulnerable(); // Make the user vulnerable to explosions if not streamerbot or chatterbot // Parse commands: if (msg.messageText.startsWith(commandPrefix)) { @@ -36,8 +36,8 @@ eventSub.onChannelChatMessage(streamerId, streamerId, async msg => { case "admin": if (!await isAdmin(user!.id)) return; break; - case "unbannable": - if (!unbannableUsers.includes(msg.chatterId)) return; + case "streamer": + if (!streamerUsers.includes(msg.chatterId)) return; break; }; diff --git a/bot/index.ts b/bot/index.ts index 4b5cf3d..63186cd 100644 --- a/bot/index.ts +++ b/bot/index.ts @@ -35,7 +35,7 @@ export const eventSub = new EventSubHttpListener({ export const commandPrefix = process.env.COMMAND_PREFIX ?? "!"; -export const unbannableUsers = [chatterId, streamerId]; -unbannableUsers.forEach(async id => await addAdmin(id)); +export const streamerUsers = [chatterId, streamerId]; +streamerUsers.forEach(async id => await addAdmin(id)); await import("./events"); diff --git a/bot/lib/timeout.ts b/bot/lib/timeout.ts index 644a234..d2b8dde 100644 --- a/bot/lib/timeout.ts +++ b/bot/lib/timeout.ts @@ -1,4 +1,4 @@ -import { streamerApi, streamerId, unbannableUsers } from ".."; +import { streamerApi, streamerId, streamerUsers } from ".."; import { User } from "../user"; type SuccessfulTimeout = { status: true }; @@ -10,7 +10,7 @@ type TimeoutResult = SuccessfulTimeout | UnSuccessfulTimeout; * @param reason - reason for timeout/ban * @param duration - duration of timeout. don't specifiy for ban */ export const timeout = async (user: User, reason: string, duration?: number): Promise => { - if (unbannableUsers.includes(user.id)) return { status: false, reason: 'illegal' }; + if (streamerUsers.includes(user.id)) return { status: false, reason: 'illegal' }; // Check if user already has a timeout const banStatus = await streamerApi.moderation.getBannedUsers(streamerId, { userId: user.id }).then(a => a.data);