fix(aurora): fixed an issue with adding multiple immune roles/addrole roles at once

This commit is contained in:
Seaswimmer 2024-04-08 11:46:22 -04:00
parent 06e011f670
commit 97b54b507b
Signed by untrusted user: cswimr
GPG key ID: B8953EC01E5C4063
2 changed files with 14 additions and 13 deletions

View file

@ -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) await interaction.response.send_message(error("You must have the manage guild permission to add roles to the addrole whitelist."), ephemeral=True)
return return
await interaction.response.defer() await interaction.response.defer()
addrole_whitelist: list = await config.guild(self.ctx.guild).addrole_whitelist() async with config.guild(self.ctx.guild).addrole_whitelist() as addrole_whitelist:
if select.values[0].id in addrole_whitelist: addrole_whitelist: list # type hint
addrole_whitelist.remove(select.values[0].id) for value in select.values:
else: if value.id in addrole_whitelist:
addrole_whitelist.append(select.values[0].id) addrole_whitelist.remove(value.id)
await config.guild(self.ctx.guild).addrole_whitelist.set(addrole_whitelist) else:
addrole_whitelist.append(value.id)
await interaction.message.edit(embed=await addrole_embed(self.ctx)) await interaction.message.edit(embed=await addrole_embed(self.ctx))
@ui.button(label="Clear", style=ButtonStyle.red, row=1) @ui.button(label="Clear", style=ButtonStyle.red, row=1)

View file

@ -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) await interaction.response.send_message(error("You must have the manage guild permission to add immune roles."), ephemeral=True)
return return
await interaction.response.defer() await interaction.response.defer()
immune_roles: list = await config.guild(self.ctx.guild).immune_roles() async with config.guild(self.ctx.guild).immune_roles() as immune_roles:
for role in select.values: immune_roles: list # type hint
if role.id in immune_roles: for value in select.values:
immune_roles.remove(role.id) if value.id in immune_roles:
else: immune_roles.remove(value.id)
immune_roles.append(role.id) else:
await config.guild(self.ctx.guild).immune_roles.set(immune_roles) immune_roles.append(value.id)
await interaction.message.edit(embed=await immune_embed(self.ctx)) await interaction.message.edit(embed=await immune_embed(self.ctx))
@ui.button(label="Clear", style=ButtonStyle.red, row=1) @ui.button(label="Clear", style=ButtonStyle.red, row=1)