feat(aurora): merged all of the changes made in the configuration rewrite into the codebase of the cog itself
This commit is contained in:
parent
3b8506cba8
commit
46a290aad3
13 changed files with 297 additions and 372 deletions
42
aurora/menus/immune.py
Normal file
42
aurora/menus/immune.py
Normal file
|
@ -0,0 +1,42 @@
|
|||
from discord import ButtonStyle, ui, Interaction
|
||||
from redbot.core import commands
|
||||
from redbot.core.utils.chat_formatting import error
|
||||
|
||||
from aurora.utilities.factory 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", min_values=0, max_values=25)
|
||||
async def immune_select(self, interaction: Interaction, select: ui.RoleSelect):
|
||||
if not interaction.user.guild_permissions.manage_guild and not interaction.user.guild_permissions.administrator:
|
||||
await interaction.response.send_message(error("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()
|
||||
for role in select.values:
|
||||
if role.id in immune_roles:
|
||||
immune_roles.remove(role.id)
|
||||
else:
|
||||
immune_roles.append(role.id)
|
||||
await config.guild(self.ctx.guild).immune_roles.set(immune_roles)
|
||||
await interaction.message.edit(embed=await immune(self.ctx))
|
||||
|
||||
@ui.button(label="Clear", style=ButtonStyle.red, row=1)
|
||||
async def clear(self, interaction: Interaction, button: ui.Button): # pylint: disable=unused-argument
|
||||
if not interaction.user.guild_permissions.manage_guild and not interaction.user.guild_permissions.administrator:
|
||||
await interaction.response.send_message(error("You must have the manage guild permission to clear the guild's immune roles."), ephemeral=True)
|
||||
return
|
||||
await interaction.response.defer()
|
||||
await config.guild(self.ctx.guild).immune_roles.clear()
|
||||
await interaction.message.edit(embed=await immune(self.ctx))
|
||||
|
||||
@ui.button(label="Close", style=ButtonStyle.gray)
|
||||
async def close(self, interaction: Interaction, button: ui.Button): # pylint: disable=unused-argument
|
||||
if not interaction.user.guild_permissions.manage_guild and not interaction.user.guild_permissions.administrator:
|
||||
await interaction.response.send_message(error("You can't do that!"), ephemeral=True)
|
||||
return
|
||||
await interaction.message.delete()
|
Loading…
Add table
Add a link
Reference in a new issue