Skip to content

Commit

Permalink
staffchat additional roles + version bump 7.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
zfbx committed Dec 10, 2021
1 parent 778342d commit e43de22
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 4 deletions.
9 changes: 9 additions & 0 deletions config.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ const DiscordGuildId = "000000000000000000";
// STAFF CHAT
const EnableStaffChatForwarding = false;
const DiscordStaffChannelId = "000000000000000000";
const AdditionalStaffChatRoleIds = [
// "000000000000000",
];

// WHITELISTING / ALLOWLISTING
const EnableWhitelistChecking = true;
Expand Down Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 3 additions & 0 deletions docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -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` ]**<br>
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

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "zdiscord",
"version": "7.0.2",
"version": "7.0.3",
"description": "Simple Discord Bot Allowlist",
"main": "server.js",
"scripts": {
Expand Down
8 changes: 5 additions & 3 deletions server/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`);
}
});
Expand All @@ -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) => {
Expand All @@ -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 ] });
}
Expand Down

0 comments on commit e43de22

Please sign in to comment.