From ac5ceadb34a0396affaebdd81d65dcf00cf438db Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 21 Jul 2026 15:31:49 +0000 Subject: [PATCH] Add noBotWizardsRoleId to block Wizard bot checkouts Adds a new role config that, when held, prevents a user from checking out a bot whose class is Wizard. Enforced both when requesting a bot by name (once its class is known) and when requesting the first available bot of a class, in both the Prisma-backed and sheet-backed account services. --- src/config.ts | 2 ++ src/services/bot/bot-prisma.ts | 9 ++++++++- src/services/bot/public-accounts-sheet.ts | 5 +++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/config.ts b/src/config.ts index 08a96ac6..e27af270 100644 --- a/src/config.ts +++ b/src/config.ts @@ -34,6 +34,7 @@ export const { raiderRoleId, inactiveRaiderRoleId, noBotsRoleId, + noBotWizardsRoleId, knightRoleId, trackerRoleId, reinforcementsRoleId, @@ -218,6 +219,7 @@ export const { inactiveRaiderRoleId: string; reinforcementsRoleId: string; noBotsRoleId: string; + noBotWizardsRoleId: string; // Guild role IDs membersAndAlliesRoleId: string; diff --git a/src/services/bot/bot-prisma.ts b/src/services/bot/bot-prisma.ts index d343a1a8..58803c0d 100644 --- a/src/services/bot/bot-prisma.ts +++ b/src/services/bot/bot-prisma.ts @@ -26,7 +26,8 @@ import { ParkBotButtonCommand } from "../../features/raid-bots/park-bot-button-c import { refreshBotEmbed } from "../../features/raid-bots/bot-embed"; import { code } from "../../shared/util"; import { MINUTES } from "../../shared/time"; -import { noBotsRoleId } from "../../config"; +import { noBotsRoleId, noBotWizardsRoleId } from "../../config"; +import { Class } from "../../shared/classes"; export class PrismaPublicAccounts implements IPublicAccountService { private refreshing: boolean = false; @@ -144,6 +145,9 @@ export class PrismaPublicAccounts implements IPublicAccountService { const foundBot = details.characters; const prismaBot = await this.getBotByName(foundBot); + if (prismaBot?.class === Class.Wizard && roles.cache.has(noBotWizardsRoleId)) { + throw new Error("You do not have permission to request Wizard bots"); + } const currentPilot = await this.getCurrentBotPilot(foundBot); const factionWarning = `${code}diff @@ -246,6 +250,9 @@ Password: ${spoiler(details.password)} bindLocation?: string | undefined ): Promise { await this.guardReady(); + if (botClass === Class.Wizard && roles.cache.has(noBotWizardsRoleId)) { + throw new Error(`You do not have permission to request a ${botClass}`); + } const bot = await prismaClient.bot.findFirst({ where: { class: botClass, diff --git a/src/services/bot/public-accounts-sheet.ts b/src/services/bot/public-accounts-sheet.ts index f10e1da0..80698d0c 100644 --- a/src/services/bot/public-accounts-sheet.ts +++ b/src/services/bot/public-accounts-sheet.ts @@ -2,8 +2,10 @@ import { GoogleSpreadsheet } from "google-spreadsheet"; import { GOOGLE_CLIENT_EMAIL, GOOGLE_PRIVATE_KEY, + noBotWizardsRoleId, publicCharactersGoogleSheetId, } from "../../config"; +import { Class } from "../../shared/classes"; import LRUCache from "lru-cache"; import { MINUTES } from "../../shared/time"; import { @@ -166,6 +168,9 @@ export class SheetPublicAccountService implements IPublicAccountService { roles: GuildMemberRoleManager, location?: string ) { + if (botClass === Class.Wizard && roles.cache.has(noBotWizardsRoleId)) { + throw new Error(`You do not have permission to request a ${botClass}`); + } await this.loadBots(); if (this.sheet) { const rows = await this.botInfoSheet.getRows();