From c255ab137cfbea2d81f42e7b72d84c2919cc7850 Mon Sep 17 00:00:00 2001 From: Oliver-Akins Date: Mon, 20 Feb 2023 20:22:21 -0700 Subject: [PATCH] Allow channel owners to run mod-only subcommands --- src/endpoints/nightbot.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/endpoints/nightbot.ts b/src/endpoints/nightbot.ts index c77b978..02b68e1 100644 --- a/src/endpoints/nightbot.ts +++ b/src/endpoints/nightbot.ts @@ -3,6 +3,11 @@ import { Request, ServerRoute } from "@hapi/hapi"; import boom from "@hapi/boom"; import Joi from "joi"; +const MOD_LEVELS = [ + `moderator`, + `owner`, +]; + interface meta { args: string[]; channel: string; @@ -118,7 +123,7 @@ const route: ServerRoute = { return `Invalid subcommand. Valid options: ${Object.keys(subcommands).join(`, `)}`; }; - if (subcommands[sc].modOnly && userData.get(`userLevel`) != `moderator`) { + if (subcommands[sc].modOnly && !MOD_LEVELS.includes(userData.get(`userLevel`) ?? ``)) { return `That command is mod-only! :P`; };