2024-02-14 11:04:26 -05:00
|
|
|
from discord import ButtonStyle, Interaction, ui
|
2024-01-15 09:58:53 -05:00
|
|
|
from redbot.core import commands
|
|
|
|
|
2024-02-14 11:04:26 -05:00
|
|
|
from aurora.utilities.config import config
|
2024-01-16 09:26:54 -05:00
|
|
|
from aurora.utilities.factory import overrides_embed
|
2024-01-16 09:23:45 -05:00
|
|
|
from aurora.utilities.utils import create_pagesize_options
|
2024-02-14 11:04:26 -05:00
|
|
|
|
|
|
|
|
2024-01-15 09:58:53 -05:00
|
|
|
|
|
|
|
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)
|
2024-02-14 11:04:26 -05:00
|
|
|
async def auto_evidenceformat(self, interaction: Interaction, button: ui.Button):
|
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()
|
2024-01-16 06:11:38 -05:00
|
|
|
if current_setting is False:
|
|
|
|
await config.user(self.ctx.author).auto_evidenceformat.clear()
|
2024-01-16 06:20:21 -05:00
|
|
|
elif current_setting is None:
|
2024-01-16 05:57:21 -05:00
|
|
|
await config.user(self.ctx.author).auto_evidenceformat.set(True)
|
2024-01-16 06:11:38 -05:00
|
|
|
else:
|
|
|
|
await config.user(self.ctx.author).auto_evidenceformat.set(False)
|
2024-01-16 09:26:54 -05:00
|
|
|
await interaction.message.edit(embed=await overrides_embed(self.ctx))
|
2024-01-16 05:57:21 -05:00
|
|
|
|
|
|
|
@ui.button(label="Ephemeral", style=ButtonStyle.green, row=0)
|
2024-02-14 11:04:26 -05:00
|
|
|
async def ephemeral(self, interaction: Interaction, button: ui.Button):
|
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()
|
2024-01-16 06:11:38 -05:00
|
|
|
if current_setting is False:
|
|
|
|
await config.user(self.ctx.author).history_ephemeral.clear()
|
2024-01-16 06:20:21 -05:00
|
|
|
elif current_setting is None:
|
2024-01-16 05:57:21 -05:00
|
|
|
await config.user(self.ctx.author).history_ephemeral.set(True)
|
2024-01-16 06:11:38 -05:00
|
|
|
else:
|
|
|
|
await config.user(self.ctx.author).history_ephemeral.set(False)
|
2024-01-16 09:26:54 -05:00
|
|
|
await interaction.message.edit(embed=await overrides_embed(self.ctx))
|
2024-01-16 05:57:21 -05:00
|
|
|
|
|
|
|
@ui.button(label="Inline", style=ButtonStyle.green, row=0)
|
2024-02-14 11:04:26 -05:00
|
|
|
async def inline(self, interaction: Interaction, button: ui.Button):
|
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()
|
2024-01-16 06:11:38 -05:00
|
|
|
if current_setting is False:
|
|
|
|
await config.user(self.ctx.author).history_inline.clear()
|
2024-01-16 06:20:21 -05:00
|
|
|
elif current_setting is None:
|
2024-01-16 05:57:21 -05:00
|
|
|
await config.user(self.ctx.author).history_inline.set(True)
|
2024-01-16 06:11:38 -05:00
|
|
|
else:
|
|
|
|
await config.user(self.ctx.author).history_inline.set(False)
|
2024-01-16 09:26:54 -05:00
|
|
|
await interaction.message.edit(embed=await overrides_embed(self.ctx))
|
2024-01-16 05:57:21 -05:00
|
|
|
|
2024-01-16 06:11:38 -05:00
|
|
|
@ui.select(placeholder="Inline Pagesize", options=create_pagesize_options(), row=1)
|
2024-01-16 08:06:50 -05:00
|
|
|
async def inline_pagesize(self, interaction: Interaction, select: ui.Select,):
|
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()
|
2024-01-16 06:18:05 -05:00
|
|
|
if select.values[0] == "default":
|
|
|
|
await config.user(self.ctx.author).history_inline_pagesize.clear()
|
|
|
|
else:
|
|
|
|
await config.user(self.ctx.author).history_inline_pagesize.set(int(select.values[0]))
|
2024-01-16 09:26:54 -05:00
|
|
|
await interaction.message.edit(embed=await overrides_embed(self.ctx))
|
2024-01-16 05:57:21 -05:00
|
|
|
|
2024-01-16 06:11:38 -05:00
|
|
|
@ui.select(placeholder="Pagesize", options=create_pagesize_options(), row=2)
|
2024-01-16 08:06:50 -05:00
|
|
|
async def pagesize(self, interaction: Interaction, select: ui.Select,):
|
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()
|
2024-01-16 06:18:05 -05:00
|
|
|
if select.values[0] == "default":
|
|
|
|
await config.user(self.ctx.author).history_pagesize.clear()
|
|
|
|
else:
|
|
|
|
await config.user(self.ctx.author).history_pagesize.set(int(select.values[0]))
|
2024-01-16 09:26:54 -05:00
|
|
|
await interaction.message.edit(embed=await overrides_embed(self.ctx))
|