diff --git a/aurora/configuration/commands.py b/aurora/configuration/commands.py index 1071f41..f5a677b 100644 --- a/aurora/configuration/commands.py +++ b/aurora/configuration/commands.py @@ -38,14 +38,14 @@ class Configuration(Mixin): """Manage the addrole whitelist. Roles added to this list are also applied to `/removerole`.""" - await ctx.send(embed=await addrole(ctx)) + await ctx.send(embed=await addrole(ctx), view=addrole(ctx)) @aurora_settings.command(name="immunity") @commands.admin_or_permissions(manage_guild=True) @commands.guild_only() async def aurora_settings_immunity(self, ctx: commands.Context): """Manage the immunity whitelist.""" - await ctx.send(embed=await immune(ctx)) + await ctx.send(embed=await immune(ctx), view=immune(ctx)) @aurora.group(autohelp=True, name="import") @commands.admin() diff --git a/aurora/configuration/menus/addrole.py b/aurora/configuration/menus/addrole.py index e69de29..1d92e57 100644 --- a/aurora/configuration/menus/addrole.py +++ b/aurora/configuration/menus/addrole.py @@ -0,0 +1,24 @@ +from discord import ui, Interaction +from redbot.core import commands + +from aurora.configuration.embed import addrole +from aurora.utilities.config import config + +class Addrole(ui.View): + def __init__(self, ctx: commands.Context): + super().__init__() + self.ctx = ctx + + @ui.select(cls=ui.RoleSelect, placeholder="Select a role") + async def addrole_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 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] in addrole_whitelist: + addrole_whitelist.remove(select.values[0]) + else: + addrole_whitelist.append(select.values[0]) + await config.guild(self.ctx.guild).addrole_whitelist.set(int(select.values[0])) + await interaction.message.edit(embed=await addrole(self.ctx)) diff --git a/aurora/configuration/menus/immune.py b/aurora/configuration/menus/immune.py index e69de29..a04c741 100644 --- a/aurora/configuration/menus/immune.py +++ b/aurora/configuration/menus/immune.py @@ -0,0 +1,24 @@ +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))