From 7613aedbbe4cecb7387afcdb68a7dc6d53ab8043 Mon Sep 17 00:00:00 2001 From: Ethan Lane Date: Fri, 18 Aug 2023 21:07:19 +0100 Subject: [PATCH] Fix muted command not working (#335) # Description - Fix muted command not working - This was caused by the muted role name still using old logic before per-server configuration #316 ## Type of change Please delete options that are not relevant. - [x] Bug fix (non-breaking change which fixes an issue) # How Has This Been Tested? - This was tested locally by running the mute and unmute commands, and seeing it the error no longer occurs # Checklist - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [ ] I have added tests that provde my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [x] Any dependent changes have been merged and published in downstream modules Reviewed-on: https://gitea.vylpes.xyz/RabbitLabs/vylbot-app/pulls/335 Co-authored-by: Ethan Lane Co-committed-by: Ethan Lane --- src/commands/mute.ts | 9 ++++++++- src/commands/unmute.ts | 9 ++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/commands/mute.ts b/src/commands/mute.ts index c012035..41d466b 100644 --- a/src/commands/mute.ts +++ b/src/commands/mute.ts @@ -54,7 +54,14 @@ export default class Mute extends Command { }, ]); - const mutedRole = interaction.guild.roles.cache.find(role => role.name == process.env.ROLES_MUTED); + const mutedRoleName = await SettingsHelper.GetSetting('role.muted', interaction.guildId); + + if (!mutedRoleName) { + await interaction.reply('Unable to find configuration. Please contact the bot author.'); + return; + } + + const mutedRole = interaction.guild.roles.cache.find(role => role.name == mutedRoleName); if (!mutedRole) { await interaction.reply('Muted role not found.'); diff --git a/src/commands/unmute.ts b/src/commands/unmute.ts index 7bbb943..2d70154 100644 --- a/src/commands/unmute.ts +++ b/src/commands/unmute.ts @@ -52,7 +52,14 @@ export default class Unmute extends Command { }, ]); - const mutedRole = interaction.guild.roles.cache.find(role => role.name == process.env.ROLES_MUTED); + const mutedRoleName = await SettingsHelper.GetSetting('role.muted', interaction.guildId); + + if (!mutedRoleName) { + await interaction.reply('Unable to find configuration. Please contact the bot author.'); + return; + } + + const mutedRole = interaction.guild.roles.cache.find(role => role.name == mutedRoleName); if (!mutedRole) { await interaction.reply('Muted role not found.');