2024-01-16 05:57:21 -05:00
|
|
|
from discord import ui, ButtonStyle, Interaction
|
2024-01-15 09:58:53 -05:00
|
|
|
from redbot.core import commands
|
|
|
|
|
|
|
|
from aurora.configuration.embed import embed
|
2024-01-16 05:57:21 -05:00
|
|
|
from aurora.configuration.utils import create_pagesize_options
|
2024-01-15 09:58:53 -05:00
|
|
|
from aurora.utilities.config import config
|
|
|
|
|
|
|
|
class Overrides(ui.View):
|
|
|
|
def __init__(self, ctx: commands.Context):
|
|
|
|
super().__init__()
|
|
|
|
self.ctx = ctx
|
|
|
|
|
2024-01-16 05:57:21 -05:00
|
|
|
@ui.button(label="Auto Evidence Format", style=ButtonStyle.green, row=0)
|
|
|
|
async def auto_evidenceformat(self, interaction: Interaction, button: ui.Button): # pylint: disable=unused-argument
|
2024-01-15 10:22:36 -05:00
|
|
|
if self.ctx.author != interaction.user:
|
2024-01-16 05:57:21 -05:00
|
|
|
await interaction.response.send_message("You cannot change this setting for other users.", ephemeral=True)
|
2024-01-15 10:22:36 -05:00
|
|
|
return
|
2024-01-16 05:57:21 -05:00
|
|
|
await interaction.response.defer()
|
|
|
|
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)
|
2024-01-16 05:36:02 -05:00
|
|
|
else:
|
2024-01-16 05:57:21 -05:00
|
|
|
await config.user(self.ctx.author).auto_evidenceformat.set(True)
|
2024-01-15 10:20:47 -05:00
|
|
|
await interaction.message.edit(embed=await embed(self.ctx))
|
2024-01-15 09:58:53 -05:00
|
|
|
|
2024-01-16 06:00:46 -05:00
|
|
|
@ui.button(label="Reset", style=ButtonStyle.red, row=1)
|
2024-01-16 05:57:21 -05:00
|
|
|
async def auto_evidenceformat_reset(self, interaction: Interaction, button: ui.Button): # pylint: disable=unused-argument
|
|
|
|
if self.ctx.author != interaction.user:
|
|
|
|
await interaction.response.send_message("You cannot change this setting for other users.", ephemeral=True)
|
|
|
|
return
|
2024-01-15 10:22:36 -05:00
|
|
|
await interaction.response.defer()
|
2024-01-16 05:57:21 -05:00
|
|
|
await config.user(self.ctx.author).auto_evidenceformat.clear()
|
|
|
|
await interaction.message.edit(embed=await embed(self.ctx))
|
|
|
|
|
|
|
|
@ui.button(label="Ephemeral", style=ButtonStyle.green, row=0)
|
|
|
|
async def ephemeral(self, interaction: Interaction, button: ui.Button): # pylint: disable=unused-argument
|
2024-01-15 10:22:36 -05:00
|
|
|
if self.ctx.author != interaction.user:
|
2024-01-16 05:57:21 -05:00
|
|
|
await interaction.response.send_message("You cannot change this setting for other users.", ephemeral=True)
|
2024-01-15 10:22:36 -05:00
|
|
|
return
|
2024-01-16 05:57:21 -05:00
|
|
|
await interaction.response.defer()
|
|
|
|
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)
|
2024-01-16 05:36:02 -05:00
|
|
|
else:
|
2024-01-16 05:57:21 -05:00
|
|
|
await config.user(self.ctx.author).history_ephemeral.set(True)
|
2024-01-15 10:22:36 -05:00
|
|
|
await interaction.message.edit(embed=await embed(self.ctx))
|
2024-01-15 09:58:53 -05:00
|
|
|
|
2024-01-16 06:00:46 -05:00
|
|
|
@ui.button(label="Reset", style=ButtonStyle.red, row=1)
|
2024-01-16 05:57:21 -05:00
|
|
|
async def ephemeral_reset(self, interaction: Interaction, button: ui.Button): # pylint: disable=unused-argument
|
|
|
|
if self.ctx.author != interaction.user:
|
|
|
|
await interaction.response.send_message("You cannot change this setting for other users.", ephemeral=True)
|
|
|
|
return
|
2024-01-15 10:22:36 -05:00
|
|
|
await interaction.response.defer()
|
2024-01-16 05:57:21 -05:00
|
|
|
await config.user(self.ctx.author).history_ephemeral.clear()
|
|
|
|
await interaction.message.edit(embed=await embed(self.ctx))
|
|
|
|
|
|
|
|
@ui.button(label="Inline", style=ButtonStyle.green, row=0)
|
|
|
|
async def inline(self, interaction: Interaction, button: ui.Button): # pylint: disable=unused-argument
|
2024-01-15 10:22:36 -05:00
|
|
|
if self.ctx.author != interaction.user:
|
2024-01-16 05:57:21 -05:00
|
|
|
await interaction.response.send_message("You cannot change this setting for other users.", ephemeral=True)
|
2024-01-15 10:22:36 -05:00
|
|
|
return
|
2024-01-16 05:57:21 -05:00
|
|
|
await interaction.response.defer()
|
|
|
|
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)
|
2024-01-16 05:36:02 -05:00
|
|
|
else:
|
2024-01-16 05:57:21 -05:00
|
|
|
await config.user(self.ctx.author).history_inline.set(True)
|
|
|
|
await interaction.message.edit(embed=await embed(self.ctx))
|
|
|
|
|
2024-01-16 06:00:46 -05:00
|
|
|
@ui.button(label="Reset", style=ButtonStyle.red, row=1)
|
2024-01-16 05:57:21 -05:00
|
|
|
async def inline_reset(self, interaction: Interaction, button: ui.Button): # pylint: disable=unused-argument
|
|
|
|
if self.ctx.author != interaction.user:
|
|
|
|
await interaction.response.send_message("You cannot change this setting for other users.", ephemeral=True)
|
|
|
|
return
|
|
|
|
await interaction.response.defer()
|
|
|
|
await config.user(self.ctx.author).history_inline.clear()
|
|
|
|
await interaction.message.edit(embed=await embed(self.ctx))
|
|
|
|
|
2024-01-16 06:00:46 -05:00
|
|
|
@ui.select(placeholder="Inline Pagesize", options=create_pagesize_options(), row=2)
|
2024-01-16 05:58:33 -05:00
|
|
|
async def inline_pagesize(self, interaction: Interaction, select: ui.Select,): # pylint: disable=unused-argument
|
2024-01-16 05:57:21 -05:00
|
|
|
if self.ctx.author != interaction.user:
|
|
|
|
await interaction.response.send_message("You cannot change this setting for other users.", ephemeral=True)
|
|
|
|
return
|
|
|
|
await interaction.response.defer()
|
|
|
|
await config.user(self.ctx.author).history_inline_pagesize.set(int(select.values[0]))
|
|
|
|
await interaction.message.edit(embed=await embed(self.ctx))
|
|
|
|
|
2024-01-16 06:04:28 -05:00
|
|
|
@ui.button(label="Reset Inline Pagesize", style=ButtonStyle.red, row=4)
|
2024-01-16 05:57:21 -05:00
|
|
|
async def inline_pagesize_reset(self, interaction: Interaction, button: ui.Button): # pylint: disable=unused-argument
|
|
|
|
if self.ctx.author != interaction.user:
|
|
|
|
await interaction.response.send_message("You cannot change this setting for other users.", ephemeral=True)
|
|
|
|
return
|
|
|
|
await interaction.response.defer()
|
|
|
|
await config.user(self.ctx.author).history_inline_pagesize.clear()
|
|
|
|
await interaction.message.edit(embed=await embed(self.ctx))
|
|
|
|
|
2024-01-16 06:00:46 -05:00
|
|
|
@ui.select(placeholder="Pagesize", options=create_pagesize_options(), row=3)
|
2024-01-16 05:58:33 -05:00
|
|
|
async def pagesize(self, interaction: Interaction, select: ui.Select,): # pylint: disable=unused-argument
|
2024-01-16 05:57:21 -05:00
|
|
|
if self.ctx.author != interaction.user:
|
|
|
|
await interaction.response.send_message("You cannot change this setting for other users.", ephemeral=True)
|
|
|
|
return
|
|
|
|
await interaction.response.defer()
|
|
|
|
await config.user(self.ctx.author).history_pagesize.set(int(select.values[0]))
|
|
|
|
await interaction.message.edit(embed=await embed(self.ctx))
|
|
|
|
|
2024-01-16 06:04:28 -05:00
|
|
|
@ui.button(label="Reset Pagesize", style=ButtonStyle.red, row=4)
|
2024-01-16 05:57:21 -05:00
|
|
|
async def pagesize_reset(self, interaction: Interaction, button: ui.Button): # pylint: disable=unused-argument
|
|
|
|
if self.ctx.author != interaction.user:
|
|
|
|
await interaction.response.send_message("You cannot change this setting for other users.", ephemeral=True)
|
|
|
|
return
|
|
|
|
await interaction.response.defer()
|
|
|
|
await config.user(self.ctx.author).history_pagesize.clear()
|
2024-01-15 10:22:36 -05:00
|
|
|
await interaction.message.edit(embed=await embed(self.ctx))
|