From 97b54b507bfafaa097cebb8038aae896a39d71ab Mon Sep 17 00:00:00 2001 From: SeaswimmerTheFsh Date: Mon, 8 Apr 2024 11:46:22 -0400 Subject: [PATCH] fix(aurora): fixed an issue with adding multiple immune roles/addrole roles at once --- aurora/menus/addrole.py | 13 +++++++------ aurora/menus/immune.py | 14 +++++++------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/aurora/menus/addrole.py b/aurora/menus/addrole.py index c6bcc6b..69f9574 100644 --- a/aurora/menus/addrole.py +++ b/aurora/menus/addrole.py @@ -17,12 +17,13 @@ class Addrole(ui.View): await interaction.response.send_message(error("You must have the manage guild permission to add roles to the addrole whitelist."), ephemeral=True) return await interaction.response.defer() - addrole_whitelist: list = await config.guild(self.ctx.guild).addrole_whitelist() - if select.values[0].id in addrole_whitelist: - addrole_whitelist.remove(select.values[0].id) - else: - addrole_whitelist.append(select.values[0].id) - await config.guild(self.ctx.guild).addrole_whitelist.set(addrole_whitelist) + async with config.guild(self.ctx.guild).addrole_whitelist() as addrole_whitelist: + addrole_whitelist: list # type hint + for value in select.values: + if value.id in addrole_whitelist: + addrole_whitelist.remove(value.id) + else: + addrole_whitelist.append(value.id) await interaction.message.edit(embed=await addrole_embed(self.ctx)) @ui.button(label="Clear", style=ButtonStyle.red, row=1) diff --git a/aurora/menus/immune.py b/aurora/menus/immune.py index b9697b6..15bf0c7 100644 --- a/aurora/menus/immune.py +++ b/aurora/menus/immune.py @@ -17,13 +17,13 @@ class Immune(ui.View): await interaction.response.send_message(error("You must have the manage guild permission to add immune roles."), ephemeral=True) return await interaction.response.defer() - immune_roles: list = await config.guild(self.ctx.guild).immune_roles() - for role in select.values: - if role.id in immune_roles: - immune_roles.remove(role.id) - else: - immune_roles.append(role.id) - await config.guild(self.ctx.guild).immune_roles.set(immune_roles) + async with config.guild(self.ctx.guild).immune_roles() as immune_roles: + immune_roles: list # type hint + for value in select.values: + if value.id in immune_roles: + immune_roles.remove(value.id) + else: + immune_roles.append(value.id) await interaction.message.edit(embed=await immune_embed(self.ctx)) @ui.button(label="Clear", style=ButtonStyle.red, row=1)