2024-01-16 07:57:42 -05:00
|
|
|
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")
|
2024-01-16 08:06:50 -05:00
|
|
|
async def addrole_select(self, interaction: Interaction, select: ui.RoleSelect,):
|
2024-01-16 08:03:51 -05:00
|
|
|
if not interaction.user.guild_permissions.manage_guild and not interaction.user.guild_permissions.administrator:
|
2024-01-16 07:57:42 -05:00
|
|
|
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()
|
2024-01-16 08:06:50 -05:00
|
|
|
if select.values[0].id in addrole_whitelist:
|
2024-01-16 08:03:51 -05:00
|
|
|
addrole_whitelist.remove(select.values[0].id)
|
2024-01-16 07:57:42 -05:00
|
|
|
else:
|
2024-01-16 08:03:51 -05:00
|
|
|
addrole_whitelist.append(select.values[0].id)
|
|
|
|
await config.guild(self.ctx.guild).addrole_whitelist.set(addrole_whitelist)
|
2024-01-16 08:06:50 -05:00
|
|
|
await interaction.message.edit(embed=await addrole(self.ctx), view=Addrole(self.ctx))
|