From 90ef4317cc6c44142de169d656645892623e0799 Mon Sep 17 00:00:00 2001 From: Ethan Lane Date: Thu, 2 Dec 2021 11:44:56 +0000 Subject: [PATCH] Update required roles checker --- .env.template | 3 ++- src/commands/mute.ts | 2 +- src/vylbot.ts | 24 +++++++++++++++--------- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/.env.template b/.env.template index 6320a30..a588213 100644 --- a/.env.template +++ b/.env.template @@ -20,12 +20,13 @@ FOLDERS_EVENTS=src/events COMMANDS_DISABLED= COMMANDS_DISABLED_MESSAGE=This command is disabled. -COMMANDS_MUTE_ROLE=Muted +COMMANDS_ROLE_ROLES=Notify,VotePings,ProjectUpdates EMBED_COLOUR=0x3050ba EMBED_COLOUR_ERROR=0xD52803 ROLES_MODERATOR=Moderator +ROLES_MUTED=Muted CHANNELS_LOGS_MESSAGE=message-logs CHANNELS_LOGS_MEMBER=member-logs diff --git a/src/commands/mute.ts b/src/commands/mute.ts index b1fe8bb..774e437 100644 --- a/src/commands/mute.ts +++ b/src/commands/mute.ts @@ -54,7 +54,7 @@ export default class Mute extends Command { const publicEmbed = new PublicEmbed(context, "", `${targetUser} has been muted`); publicEmbed.AddReason(reason); - const mutedRole = context.message.guild.roles.cache.find(role => role.name == process.env.COMMANDS_MUTE_ROLE); + const mutedRole = context.message.guild.roles.cache.find(role => role.name == process.env.ROLES_MUTED); if (!mutedRole) { const embed = new ErrorEmbed(context, ErrorMessages.RoleNotFound); diff --git a/src/vylbot.ts b/src/vylbot.ts index ed42734..301c8f0 100644 --- a/src/vylbot.ts +++ b/src/vylbot.ts @@ -3,16 +3,22 @@ import * as dotenv from "dotenv"; dotenv.config(); -// Ensure required data is in dotenv -if (!process.env.EMBED_COLOUR) throw "EMBED_COLOUR is required in .env"; -if (!process.env.EMBED_COLOUR_ERROR) throw "EMBED_COLOUR_ERROR is required in .env"; +const requiredConfigs = [ + "EMBED_COLOUR", + "EMBED_COLOUR_ERROR", + "ROLES_MODERATOR", + "ROLES_MUTED", + "CHANNELS_LOGS_MESSAGE", + "CHANNELS_LOGS_MEMBER", + "CHANNELS_LOGS_MOD", + "COMMANDS_ROLE_ROLES" +]; -if (!process.env.ROLES_MODERATOR) throw "ROLES_MODERATOR is required in .env"; - -if (!process.env.CHANNELS_LOGS_MESSAGE) throw "CHANNELS_LOGS_MESSAGE is required in .env"; -if (!process.env.CHANNELS_LOGS_MEMBER) throw "CHANNELS_LOGS_MEMBER is required in .env"; -if (!process.env.CHANNELS_LOGS_MOD) throw "CHANNELS_LOGS_MOD is required in .env"; -if (!process.env.COMMANDS_MUTE_ROLE) throw "COMMANDS_MUTE_ROLE is required in .env"; +requiredConfigs.forEach(config => { + if (!process.env[config]) { + throw `${config} is required in .env`; + } +}); const client = new CoreClient(); client.start(); \ No newline at end of file