From 3294d9ca7775a4296dd21e32ba8d6bc726aef575 Mon Sep 17 00:00:00 2001 From: mightypanders Date: Thu, 8 Jun 2023 17:10:06 +0200 Subject: [PATCH] make jf roles configurable via env vars --- server/configuration.ts | 6 +++++- server/helper/roleFilter.ts | 7 ++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/server/configuration.ts b/server/configuration.ts index 6c10ff7..fa3d020 100644 --- a/server/configuration.ts +++ b/server/configuration.ts @@ -20,6 +20,8 @@ export interface Config { jellyfin_url: string port: number workaround_token: string + watcher_role: string + jf_admin_role: string } } export const config: Config = { @@ -49,6 +51,8 @@ export const config: Config = { client_id: process.env.CLIENT_ID ?? "", jellfin_token: process.env.JELLYFIN_TOKEN ?? "", jellyfin_url: process.env.JELLYFIN_URL ?? "", - workaround_token: process.env.TOKEN ?? "" + workaround_token: process.env.TOKEN ?? "", + watcher_role: process.env.WATCHER_ROLE ?? "", + jf_admin_role: process.env.ADMIN_ROLE ?? "" } } diff --git a/server/helper/roleFilter.ts b/server/helper/roleFilter.ts index 7d64efe..f36f577 100644 --- a/server/helper/roleFilter.ts +++ b/server/helper/roleFilter.ts @@ -1,6 +1,7 @@ import { Collection, GuildMember } from "discord.js" import { ChangedRoles, PermissionLevel } from "../interfaces" import { logger } from "../logger" +import { config } from "../configuration" export function filterRolesFromMemberUpdate(oldMember: GuildMember, newMember: GuildMember): ChangedRoles { @@ -17,7 +18,7 @@ export function filterRolesFromMemberUpdate(oldMember: GuildMember, newMember: G export function getGuildSpecificTriggerRoleId(guildId: string): Collection { const outVal = new Collection() - outVal.set('1096819983889215659', "VIEWER") - outVal.set('1097990848613986526', "ADMIN") + outVal.set(config.bot.watcher_role, "VIEWER") + outVal.set(config.bot.jf_admin_role, "ADMIN") return outVal -} \ No newline at end of file +}