SeaCogs/aurora/configuration/menus/overrides.py
SeaswimmerTheFsh 7ae16ea258
All checks were successful
Actions / Lint Code (Pylint) (pull_request) Successful in 18s
Actions / Build Documentation (MkDocs) (pull_request) Successful in 13s
feat(aurora): moving to select menus for user overrides
2024-01-16 10:31:11 +00:00

49 lines
2.5 KiB
Python

from discord import ui, ButtonStyle, Interaction, SelectOption
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.select(cls=ui.Select, placeholder="Auto Evidence Format", row=0, options=[
SelectOption(label="Enabled", value=True, emoji=""),
SelectOption(label="Disabled", value=False, emoji=""),
SelectOption(label="Default", value=None, emoji="🔁")
])
async def auto_evidenceformat(self, interaction: Interaction, select: ui.Select): # pylint: disable=unused-argument
await interaction.response.defer()
if self.ctx.author != interaction.user:
await interaction.followup.send("You cannot change this setting for other users.", ephemeral=True)
return
await config.user(self.ctx.author).auto_evidenceformat.set(select.values[0])
await interaction.message.edit(embed=await embed(self.ctx))
@ui.button(label="Ephemeral (U)", style=ButtonStyle.green, row=0)
async def ephemeral(self, interaction: Interaction, button: ui.Button): # pylint: disable=unused-argument
await interaction.response.defer()
if self.ctx.author != interaction.user:
await interaction.followup.send("You cannot change this setting for other users.", ephemeral=True)
return
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 interaction.message.edit(embed=await embed(self.ctx))
@ui.button(label="Inline (U)", style=ButtonStyle.green, row=0)
async def inline(self, interaction: Interaction, button: ui.Button): # pylint: disable=unused-argument
await interaction.response.defer()
if self.ctx.author != interaction.user:
await interaction.followup.send("You cannot change this setting for other users.", ephemeral=True)
return
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 interaction.message.edit(embed=await embed(self.ctx))