feat(aurora): added configuration menu for guild

This commit is contained in:
Seaswimmer 2024-01-16 14:02:10 +00:00
parent 4db7c912cb
commit 3d4b6800a5
Signed by untrusted user: cswimr
GPG key ID: D74DDDDF420E13DF
2 changed files with 126 additions and 1 deletions

View file

@ -2,6 +2,7 @@ from redbot.core import commands
from redbot.core.utils.chat_formatting import error, warning from redbot.core.utils.chat_formatting import error, warning
from aurora.configuration.menus.addrole import Addrole from aurora.configuration.menus.addrole import Addrole
from aurora.configuration.menus.guild import Guild
from aurora.configuration.menus.immune import Immune from aurora.configuration.menus.immune import Immune
from aurora.configuration.menus.overrides import Overrides from aurora.configuration.menus.overrides import Overrides
from aurora.configuration.embed import addrole, overrides, immune, guild from aurora.configuration.embed import addrole, overrides, immune, guild
@ -31,7 +32,7 @@ class Configuration(Mixin):
@commands.guild_only() @commands.guild_only()
async def aurora_settings_guild(self, ctx: commands.Context): async def aurora_settings_guild(self, ctx: commands.Context):
"""Manage Aurora's guild settings.""" """Manage Aurora's guild settings."""
await ctx.send(embed=await guild(ctx)) await ctx.send(embed=await guild(ctx), view=Guild(ctx))
@aurora_settings.command(name="addrole", aliases=["removerole"]) @aurora_settings.command(name="addrole", aliases=["removerole"])
@commands.admin_or_permissions(manage_guild=True) @commands.admin_or_permissions(manage_guild=True)

View file

@ -0,0 +1,124 @@
from discord import ui, ButtonStyle, Interaction
from redbot.core import commands
from aurora.configuration.embed import guild
from aurora.configuration.utils import create_pagesize_options
from aurora.utilities.config import config
class Guild(ui.View):
def __init__(self, ctx: commands.Context):
super().__init__()
self.ctx = ctx
@ui.button(label="Show Moderator", style=ButtonStyle.green, row=0)
async def show_modeartor(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("You must have the manage guild permission to change this setting.", ephemeral=True)
return
await interaction.response.defer()
current_setting = await config.guild(interaction.guild).show_modeartor
await config.guild(interaction.guild).show_modeartor.set(not current_setting)
await interaction.message.edit(embed=await guild(self.ctx))
@ui.button(label="Use Discord Permissions", style=ButtonStyle.green, row=0)
async def use_discord_permissions(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("You must have the manage guild permission to change this setting.", ephemeral=True)
return
await interaction.response.defer()
current_setting = await config.guild(interaction.guild).use_discord_permissions()
await config.guild(interaction.guild).use_discord_permissions.set(not current_setting)
await interaction.message.edit(embed=await guild(self.ctx))
@ui.button(label="Ignore Modlog", style=ButtonStyle.green, row=0)
async def ignore_modlog(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("You must have the manage guild permission to change this setting.", ephemeral=True)
return
await interaction.response.defer()
current_setting = await config.guild(interaction.guild).ignore_modlog()
await config.guild(interaction.guild).ignore_modlog.set(not current_setting)
await interaction.message.edit(embed=await guild(self.ctx))
@ui.button(label="Ignore Other Bots", style=ButtonStyle.green, row=0)
async def ignore_other_bots(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("You must have the manage guild permission to change this setting.", ephemeral=True)
return
await interaction.response.defer()
current_setting = await config.guild(interaction.guild).ignore_other_bots()
await config.guild(interaction.guild).ignore_other_bots.set(not current_setting)
await interaction.message.edit(embed=await guild(self.ctx))
@ui.button(label="DM Users", style=ButtonStyle.green, row=0)
async def dm_users(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("You must have the manage guild permission to change this setting.", ephemeral=True)
return
await interaction.response.defer()
current_setting = await config.guild(interaction.guild).dm_users()
await config.guild(interaction.guild).dm_users.set(not current_setting)
await interaction.message.edit(embed=await guild(self.ctx))
@ui.select(placeholder="Log Channel", cls=ui.ChannelSelect, row=1)
async def log_channel(self, interaction: Interaction, select: ui.ChannelSelect):
if not interaction.user.guild_permissions.manage_guild and not interaction.user.guild_permissions.administrator:
await interaction.response.send_message("You must have the manage guild permission to change this setting.", ephemeral=True)
return
await interaction.response.defer()
await config.guild(interaction.guild).log_channel.set(select.values[0].id)
await interaction.message.edit(embed=await guild(self.ctx))
@ui.button(label="Auto Evidence Format", style=ButtonStyle.green, row=2)
async def auto_evidenceformat(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("You must have the manage guild permission to change this setting.", ephemeral=True)
return
await interaction.response.defer()
current_setting = await config.guild(interaction.guild).auto_evidenceformat()
await config.guild(interaction.guild).auto_evidenceformat.set(not current_setting)
await interaction.message.edit(embed=await guild(self.ctx))
@ui.button(label="Ephemeral", style=ButtonStyle.green, row=2)
async def ephemeral(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("You must have the manage guild permission to change this setting.", ephemeral=True)
return
await interaction.response.defer()
current_setting = await config.guild(interaction.guild).history_ephemeral()
await config.guild(interaction.guild).history_ephemeral.set(not current_setting)
await interaction.message.edit(embed=await guild(self.ctx))
@ui.button(label="History Inline", style=ButtonStyle.green, row=2)
async def inline(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("You must have the manage guild permission to change this setting.", ephemeral=True)
return
await interaction.response.defer()
current_setting = await config.guild(interaction.guild).history_inline()
await config.guild(interaction.guild).history_inline.set(not current_setting)
await interaction.message.edit(embed=await guild(self.ctx))
@ui.select(placeholder="History Pagesize", options=create_pagesize_options(), row=3)
async def pagesize(self, interaction: Interaction, select: ui.Select,):
if not interaction.user.guild_permissions.manage_guild and not interaction.user.guild_permissions.administrator:
await interaction.response.send_message("You must have the manage guild permission to change this setting.", ephemeral=True)
return
if select.values[0] == "default":
await config.guild(interaction.guild).history_pagesize.clear()
else:
await config.guild(interaction.guild).history_pagesize.set(int(select.values[0]))
await interaction.response.defer()
await interaction.message.edit(embed=await guild(self.ctx))
@ui.select(placeholder="History Inline Pagesize", options=create_pagesize_options(), row=4)
async def inline_pagesize(self, interaction: Interaction, select: ui.Select,):
if not interaction.user.guild_permissions.manage_guild and not interaction.user.guild_permissions.administrator:
await interaction.response.send_message("You must have the manage guild permission to change this setting.", ephemeral=True)
return
if select.values[0] == "default":
await config.guild(interaction.guild).history_inline_pagesize.clear()
else:
await config.guild(interaction.guild).history_inline_pagesize.set(int(select.values[0]))
await interaction.response.defer()
await interaction.message.edit(embed=await guild(self.ctx))