feat(aurora): adding the first parts of menu configs
Some checks failed
Actions / Lint Code (Pylint) (pull_request) Failing after 16s
Actions / Build Documentation (MkDocs) (pull_request) Successful in 12s

This commit is contained in:
Seaswimmer 2024-01-15 14:58:53 +00:00
parent ebccec54bf
commit 14705efddd
Signed by: cswimr
GPG key ID: D74DDDDF420E13DF
4 changed files with 47 additions and 6 deletions

View file

@ -21,7 +21,8 @@ class Configuration(Mixin):
@aurora_settings.command(name="core")
async def aurora_settings_core(self, ctx: commands.Context):
"""Manage Aurora's core settings."""
await ctx.send(embed=await embed(ctx))
menu = await embed(ctx)
await ctx.send(embed=menu[0], view=menu[1])
@aurora_settings.command(name="addrole", aliases=["removerole"])
@commands.admin_or_permissions(manage_guild=True)

View file

@ -1,11 +1,12 @@
from typing import Union
from discord import Embed, Guild, Member, User
from discord import Embed, Guild, Member, User, ui
from redbot.core import commands
from redbot.core.utils.chat_formatting import bold, error, warning
from .utils import get_bool_emoji, get_pagesize_str
from ..utilities.config import config
from aurora.configuration.menus.core import Overrides
from aurora.configuration.utils import get_bool_emoji, get_pagesize_str
from aurora.utilities.config import config
async def _core(ctx: commands.Context) -> Embed:
"""Generates the core embed for configuration menus to use."""
@ -100,13 +101,15 @@ async def _immune(guild: Guild) -> str:
immune = warning("No roles are set as immune roles!")
return immune
async def embed(ctx: commands.Context) -> Embed:
async def embed(ctx: commands.Context) -> (Embed, ui.View):
"""Generates the configuration embed for a guild."""
e = await _core(ctx)
e.add_field(name="User Overrides", value=await _overrides(ctx.author), inline=False)
view = Overrides(ctx)
if ctx.guild is not None and (ctx.author.guild_permissions.administrator or ctx.author.guild_permissions.manage_guild):
e.add_field(name="Guild Settings", value=await _guild(ctx.guild), inline=False)
return e
view = None
return (e, view)
async def addrole_embed(ctx: commands.Context) -> Embed:
"""Generates the addrole embed for a guild."""

View file

@ -0,0 +1,37 @@
from discord import ui, ButtonStyle, Interaction
from redbot.core import commands
from aurora.configuration.embed import embed
from aurora.utilities.config import config
class Overrides(ui.View):
def __init__(self, ctx: commands.Context):
super().__init__()
self.ctx = ctx
@ui.button(label="Auto Evidence Format", style=ButtonStyle.green)
async def auto_evidenceformat(self, interaction: Interaction, button: ui.Button): # pylint: disable=unused-argument
current_setting = await config.user(self.ctx.author).auto_evidenceformat()
if current_setting:
await config.user(self.ctx.author).auto_evidenceformat.set(not current_setting)
else:
await config.user(self.ctx.author).auto_evidenceformat.set(True)
await self.ctx.message.edit(embed=await embed(self.ctx))
@ui.button(label="Ephemeral", style=ButtonStyle.green)
async def ephemeral(self, interaction: Interaction, button: ui.Button): # pylint: disable=unused-argument
current_setting = await config.user(self.ctx.author).history_ephemeral()
if current_setting:
await config.user(self.ctx.author).history_ephemeral.set(not current_setting)
else:
await config.user(self.ctx.author).history_ephemeral.set(True)
await self.ctx.message.edit(embed=await embed(self.ctx))
@ui.button(label="Inline", style=ButtonStyle.green)
async def inline(self, interaction: Interaction, button: ui.Button): # pylint: disable=unused-argument
current_setting = await config.user(self.ctx.author).history_inline()
if current_setting:
await config.user(self.ctx.author).history_inline.set(not current_setting)
else:
await config.user(self.ctx.author).history_inline.set(True)
await self.ctx.message.edit(embed=await embed(self.ctx))