Skip to content

Commit

Permalink
feat(astral-ruff): Minimal response and ephemeral expand (#70)
Browse files Browse the repository at this point in the history
* feat(astral-ruff): Minimal response and ephemeral expand

* Update src/byte/views/astral.py

---------

Co-authored-by: Alc-Alc <alc@localhost>
Co-authored-by: Jacob Coffee <jacob@z7x.org>
  • Loading branch information
3 people authored Feb 28, 2024
1 parent 42c1d19 commit 56203b1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 26 deletions.
2 changes: 1 addition & 1 deletion src/byte/plugins/astral.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ async def ruff_rule(self, interaction: Interaction, rule: str) -> None:
embed.set_thumbnail(url=ruff_logo)

view = RuffView(author=interaction.user.id, bot=self.bot, original_embed=embed, minified_embed=minified_embed)
await interaction.followup.send(embed=embed, view=view)
await interaction.followup.send(embed=minified_embed, view=view)

@app_command(name="format")
async def format_code(self, interaction: Interaction, code_block: str) -> None: # noqa: ARG002
Expand Down
31 changes: 6 additions & 25 deletions src/byte/views/astral.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,18 +72,9 @@ async def collapse_button_callback(self, interaction: Interaction) -> None:
"""
await interaction.response.edit_message(embed=self.minified_embed, view=self)

async def expand_button_callback(self, interaction: Interaction) -> None:
"""Expand the message to show full information.
Args:
interaction: Interaction object.
button: Button object.
"""
await interaction.message.edit(embed=self.original_embed, view=self)

# Define buttons using decorators
@button(label="Delete", style=ButtonStyle.red, custom_id="delete_button")
async def delete_button(self, interaction: Interaction, button: Button[Self]) -> None:
async def delete_button(self, interaction: Interaction, _: Button[Self]) -> None:
"""Button to delete the message this view is attached to.
Args:
Expand All @@ -92,22 +83,12 @@ async def delete_button(self, interaction: Interaction, button: Button[Self]) ->
"""
await self.delete_button_callback(interaction)

@button(label="Collapse", style=ButtonStyle.grey, custom_id="collapse_button")
async def collapse_button(self, interaction: Interaction, button: Button[Self]) -> None:
"""Button to minify the embed to show less information but not none.
@button(label="Learn More", style=ButtonStyle.green, custom_id="learn_more_button")
async def learn_more_button(self, interaction: Interaction, _: Button[Self]) -> None:
"""Button to privately message the requesting user the full embed.
Args:
interaction: Interaction object.
button: Button object.
"""
await self.collapse_button_callback(interaction)

@button(label="Expand", style=ButtonStyle.green, custom_id="expand_button", disabled=True)
async def expand_button(self, interaction: Interaction, button: Button[Self]) -> None:
"""Button to expand the embed to show full information.
Args:
interaction: Interaction object.
button: Button object.
_: Button object.
"""
await self.expand_button_callback(interaction, button)
await interaction.response.send_message(embed=self.original_embed, ephemeral=True)

0 comments on commit 56203b1

Please sign in to comment.