From 56857554e9a242b4064fb403fdf84eade478e331 Mon Sep 17 00:00:00 2001 From: SeaswimmerTheFsh Date: Tue, 16 Jan 2024 11:11:38 +0000 Subject: [PATCH] fix(aurora): changed a whole bunch of stuff in the user override config menu --- aurora/configuration/menus/overrides.py | 73 ++++++------------------- aurora/configuration/utils.py | 21 +++++-- 2 files changed, 32 insertions(+), 62 deletions(-) diff --git a/aurora/configuration/menus/overrides.py b/aurora/configuration/menus/overrides.py index 5e3d4f9..941bb94 100644 --- a/aurora/configuration/menus/overrides.py +++ b/aurora/configuration/menus/overrides.py @@ -17,19 +17,12 @@ class Overrides(ui.View): return 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) - else: + if current_setting is False: + await config.user(self.ctx.author).auto_evidenceformat.clear() + if current_setting is None: await config.user(self.ctx.author).auto_evidenceformat.set(True) - await interaction.message.edit(embed=await embed(self.ctx)) - - @ui.button(label="Reset", style=ButtonStyle.red, row=1) - 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 - await interaction.response.defer() - await config.user(self.ctx.author).auto_evidenceformat.clear() + else: + await config.user(self.ctx.author).auto_evidenceformat.set(False) await interaction.message.edit(embed=await embed(self.ctx)) @ui.button(label="Ephemeral", style=ButtonStyle.green, row=0) @@ -39,19 +32,12 @@ class Overrides(ui.View): return 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) - else: + if current_setting is False: + await config.user(self.ctx.author).history_ephemeral.clear() + if current_setting is None: await config.user(self.ctx.author).history_ephemeral.set(True) - await interaction.message.edit(embed=await embed(self.ctx)) - - @ui.button(label="Reset", style=ButtonStyle.red, row=1) - 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 - await interaction.response.defer() - await config.user(self.ctx.author).history_ephemeral.clear() + else: + await config.user(self.ctx.author).history_ephemeral.set(False) await interaction.message.edit(embed=await embed(self.ctx)) @ui.button(label="Inline", style=ButtonStyle.green, row=0) @@ -61,22 +47,15 @@ class Overrides(ui.View): return 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) - else: + if current_setting is False: + await config.user(self.ctx.author).history_inline.clear() + if current_setting is None: await config.user(self.ctx.author).history_inline.set(True) + else: + await config.user(self.ctx.author).history_inline.set(False) await interaction.message.edit(embed=await embed(self.ctx)) - @ui.button(label="Reset", style=ButtonStyle.red, row=1) - 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)) - - @ui.select(placeholder="Inline Pagesize", options=create_pagesize_options(), row=2) + @ui.select(placeholder="Inline Pagesize", options=create_pagesize_options(), row=1) async def inline_pagesize(self, interaction: Interaction, select: ui.Select,): # 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) @@ -85,16 +64,7 @@ class Overrides(ui.View): await config.user(self.ctx.author).history_inline_pagesize.set(int(select.values[0])) await interaction.message.edit(embed=await embed(self.ctx)) - @ui.button(label="Reset Inline Pagesize", style=ButtonStyle.red, row=4) - 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)) - - @ui.select(placeholder="Pagesize", options=create_pagesize_options(), row=3) + @ui.select(placeholder="Pagesize", options=create_pagesize_options(), row=2) async def pagesize(self, interaction: Interaction, select: ui.Select,): # 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) @@ -102,12 +72,3 @@ class Overrides(ui.View): 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)) - - @ui.button(label="Reset Pagesize", style=ButtonStyle.red, row=4) - 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() - await interaction.message.edit(embed=await embed(self.ctx)) diff --git a/aurora/configuration/utils.py b/aurora/configuration/utils.py index c836cf4..fab5426 100644 --- a/aurora/configuration/utils.py +++ b/aurora/configuration/utils.py @@ -18,11 +18,20 @@ def get_pagesize_str(value: Union[int, None]) -> str: def create_pagesize_options() -> list[SelectOption]: """Returns a list of SelectOptions for pagesize configuration.""" - return [ + options = [] + options.append( SelectOption( - label=str(i), - value=str(i), - description=f"Set the pagesize to {i}.", + label="Default", + value="default", + description="Reset the pagesize to the default value.", ) - for i in range(1, 21) - ] + ) + for i in range(1, 21): + options.append( + SelectOption( + label=str(i), + value=str(i), + description=f"Set the pagesize to {i}.", + ) + ) + return options