SeaCogs/aurora/configuration/menus/core.py

50 lines
2.5 KiB
Python
Raw Normal View History

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
await interaction.response.defer()
if self.ctx.author != interaction.user:
await interaction.response.send_message("You cannot change this setting for other users.", ephemeral=True)
return
current_setting = await config.user(self.ctx.author).auto_evidenceformat()
if current_setting is not None:
await config.user(self.ctx.author).auto_evidenceformat.set(not current_setting)
else:
await config.user(self.ctx.author).auto_evidenceformat.set(True)
await interaction.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
await interaction.response.defer()
if self.ctx.author != interaction.user:
await interaction.response.send_message("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", style=ButtonStyle.green)
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.response.send_message("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))