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();