SeaCogs/aurora/configuration/menus/addrole.py
SeaswimmerTheFsh 13e82f8768
Some checks failed
Actions / Lint Code (Pylint) (pull_request) Failing after 18s
Actions / Build Documentation (MkDocs) (pull_request) Successful in 13s
feat(aurora): added views for addrole and immunity
2024-01-16 12:57:42 +00:00

24 lines
1.1 KiB
Python

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))