From e43de22e2638be29c745a56ba76b3660e3ed859d Mon Sep 17 00:00:00 2001 From: Tony <1414927+zfbx@users.noreply.github.com> Date: Fri, 10 Dec 2021 18:23:38 -0500 Subject: [PATCH] staffchat additional roles + version bump 7.0.3 --- config.js | 9 +++++++++ docs/changelog.md | 5 +++++ docs/config.md | 3 +++ package.json | 2 +- server/server.js | 8 +++++--- 5 files changed, 23 insertions(+), 4 deletions(-) diff --git a/config.js b/config.js index 6e9c291..187b363 100644 --- a/config.js +++ b/config.js @@ -29,6 +29,9 @@ const DiscordGuildId = "000000000000000000"; // STAFF CHAT const EnableStaffChatForwarding = false; const DiscordStaffChannelId = "000000000000000000"; +const AdditionalStaffChatRoleIds = [ + // "000000000000000", +]; // WHITELISTING / ALLOWLISTING const EnableWhitelistChecking = true; @@ -101,6 +104,12 @@ module.exports = { LoggingWebhooks: LoggingWebhooks, LoggingAlertPingId: GetConvar("discord_logging_ping_id", LoggingAlertPingId), LoggingWebhookName: GetConvar("discord_logging_name", LoggingWebhookName), + StaffChatRoleIds: [ + GetConvar("discord_mod_role", DiscordModRoleId), + GetConvar("discord_admin_role", DiscordAdminRoleId), + GetConvar("discord_god_role", DiscordGodRoleId), + ...AdditionalStaffChatRoleIds, + ], }; /** Returns convar or default value fixed to a true/false boolean diff --git a/docs/changelog.md b/docs/changelog.md index 4c6a5ae..3a26fda 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -1,5 +1,10 @@ ## Change log +**7.0.3 - Fixes + New config for addl staffchat roles [2021-12-10]** + +- fixed a few logging typos +- added new config `AdditionalStaffChatRoleIds` (read config docs for more info) + **7.0.2 - New languages and hot fixes [2021-12-9]** - added Bulgarian from @WrecksBG diff --git a/docs/config.md b/docs/config.md index 2479134..4dd0467 100644 --- a/docs/config.md +++ b/docs/config.md @@ -61,6 +61,9 @@ This set to "true" will enable the feature of forwarding chat from in game to di **[ Convar: `discord_staff_channel_id` ]**
This is the channel staff chat will be sent and be taken from to send to staff in game. this can only be 1 channel and some things might not look the same in game as they do in discord like emoji or @mentions but that's normal. +### AdditionalStaffChatRoleIds +if you have extra roles you'd like to access staff chat other than the default mod, admin and god roles configured below you can add other roles here and they'll have access to see and toggle staff chat. Just make sure they can also see the DiscordStaffChannelId channel ;) + ## Whitelisting / Allowlisting diff --git a/package.json b/package.json index 075f831..4e2e1ff 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "zdiscord", - "version": "7.0.2", + "version": "7.0.3", "description": "Simple Discord Bot Allowlist", "main": "server.js", "scripts": { diff --git a/server/server.js b/server/server.js index d6cea04..a1b251b 100644 --- a/server/server.js +++ b/server/server.js @@ -71,7 +71,7 @@ on("playerJoining", (oldId) => { } } } - if (z.bot.isRolePresent(member, [ z.config.DiscordModRoleId, z.config.DiscordAdminRoleId, z.config.DiscordGodRoleId ])) { + if (z.bot.isRolePresent(member, z.config.StaffChatRoleIds)) { ExecuteCommand(`add_principal "player.${source}" group.zdiscordstaff`); } }); @@ -93,7 +93,9 @@ if (z.config.EnableStaffChatForwarding) { if (!z.config.EnableDiscordBot) return; const staffChannel = z.bot.channels.cache.get(z.config.DiscordStaffChannelId); if (!staffChannel) return z.utils.log.warn("DiscordStaffChannelId was not found, staff message not sent."); - staffChannel.send({ content: `${GetPlayerName(source)}: ${raw.substring(6)}`, allowMentions: false }); + staffChannel.send({ content: `${GetPlayerName(source)}: ${raw.substring(6)}`, allowMentions: false }).catch((e) => { + z.utils.log.error("I don't seem to have the required permissions to forward the staffchat to the configured staffchannel"); + }); }, "zdiscord.staffchat"); RegisterCommand("stafftoggle", (source, args, raw) => { @@ -102,7 +104,7 @@ if (z.config.EnableStaffChatForwarding) { z.utils.chatMessage(source, z.locale.staffchat, "Staff chat disabled.", { color: [ 255, 255, 0 ] }); } else { const member = z.bot.getMemberFromSource(source); - if (z.bot.isRolePresent(member, [ z.config.DiscordModRoleId, z.config.DiscordAdminRoleId, z.config.DiscordGodRoleId ])) { + if (z.bot.isRolePresent(member, z.config.StaffChatRoleIds)) { ExecuteCommand(`add_principal "player.${source}" group.zdiscordstaff`); z.utils.chatMessage(source, z.locale.staffchat, "Staff chat enabled.", { color: [ 255, 255, 0 ] }); }