from discord import ui, Interaction from redbot.core import commands from aurora.configuration.embed import immune from aurora.utilities.config import config class Immune(ui.View): def __init__(self, ctx: commands.Context): super().__init__() self.ctx = ctx @ui.select(cls=ui.RoleSelect, placeholder="Select a role") async def immune_select(self, interaction: Interaction, select: ui.RoleSelect,): # pylint: disable=unused-argument if not interaction.user.guild_permissions.manage_guild: await interaction.response.send_message("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() if select.values[0] in immune_roles: immune_roles.remove(select.values[0]) else: immune_roles.append(select.values[0]) await config.guild(self.ctx.guild).immune_roles.set(int(select.values[0])) await interaction.message.edit(embed=await immune(self.ctx))