Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export const {
raiderRoleId,
inactiveRaiderRoleId,
noBotsRoleId,
noBotWizardsRoleId,
knightRoleId,
trackerRoleId,
reinforcementsRoleId,
Expand Down Expand Up @@ -218,6 +219,7 @@ export const {
inactiveRaiderRoleId: string;
reinforcementsRoleId: string;
noBotsRoleId: string;
noBotWizardsRoleId: string;

// Guild role IDs
membersAndAlliesRoleId: string;
Expand Down
9 changes: 8 additions & 1 deletion src/services/bot/bot-prisma.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -246,6 +250,9 @@ Password: ${spoiler(details.password)}
bindLocation?: string | undefined
): Promise<string> {
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,
Expand Down
5 changes: 5 additions & 0 deletions src/services/bot/public-accounts-sheet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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();
Expand Down
Loading