From e20a03fbff7550c219888d0c6a2bba80c3f0aea0 Mon Sep 17 00:00:00 2001 From: trag1c Date: Fri, 27 Dec 2024 10:26:24 +0100 Subject: [PATCH 1/2] refactor: rename the message-moving feature files --- app/features/__init__.py | 4 ++-- app/features/{mod.py => move_message.py} | 0 app/view/__init__.py | 2 +- app/view/{mod.py => move_message.py} | 0 4 files changed, 3 insertions(+), 3 deletions(-) rename app/features/{mod.py => move_message.py} (100%) rename app/view/{mod.py => move_message.py} (100%) diff --git a/app/features/__init__.py b/app/features/__init__.py index a8d340e..c39f411 100644 --- a/app/features/__init__.py +++ b/app/features/__init__.py @@ -1,3 +1,3 @@ -from app.features import entity_mentions, mod +from app.features import entity_mentions, move_message -__all__ = ("entity_mentions", "mod") +__all__ = ("entity_mentions", "move_message") diff --git a/app/features/mod.py b/app/features/move_message.py similarity index 100% rename from app/features/mod.py rename to app/features/move_message.py diff --git a/app/view/__init__.py b/app/view/__init__.py index 5888eac..92849c5 100644 --- a/app/view/__init__.py +++ b/app/view/__init__.py @@ -1,4 +1,4 @@ from app.view.entity_mentions import DeleteMention -from app.view.mod import SelectChannel +from app.view.move_message import SelectChannel __all__ = ("DeleteMention", "SelectChannel") diff --git a/app/view/mod.py b/app/view/move_message.py similarity index 100% rename from app/view/mod.py rename to app/view/move_message.py From 7e2a67980eaea1541477304831191dcf742d8e70 Mon Sep 17 00:00:00 2001 From: trag1c Date: Fri, 27 Dec 2024 10:58:48 +0100 Subject: [PATCH 2/2] feat: add a button to ghostping after message move --- app/view/move_message.py | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/app/view/move_message.py b/app/view/move_message.py index 23fbdd7..e591067 100644 --- a/app/view/move_message.py +++ b/app/view/move_message.py @@ -1,3 +1,5 @@ +from typing import cast + import discord from app.setup import bot @@ -40,5 +42,32 @@ async def select_channel( webhook = await get_or_create_webhook("Ghostty Moderator", webhook_channel) await move_message_via_webhook(webhook, self.message, self.executor, thread) await interaction.followup.send( - content=f"Moved the message to {channel.mention}." + content=f"Moved the message to {channel.mention}.", + view=Ghostping( + cast(discord.Member, self.message.author), + cast(discord.abc.Messageable, channel), + ), + ) + + +class Ghostping(discord.ui.View): + def __init__( + self, author: discord.Member, channel: discord.abc.Messageable + ) -> None: + super().__init__() + self._author = author + self._channel = channel + + @discord.ui.button( + label="Ghostping", + emoji="👻", + style=discord.ButtonStyle.secondary, + ) + async def ghostping( + self, interaction: discord.Interaction, but: discord.ui.Button + ) -> None: + await interaction.response.defer(ephemeral=True) + await (await self._channel.send(self._author.mention)).delete() + await interaction.followup.send( + f"Ghostpinged {self._author.name}.", ephemeral=True )