Skip to content

Commit

Permalink
Merge pull request #72 from trag1c/move-message-ghostping
Browse files Browse the repository at this point in the history
feat: add a button to ghostping after message move
  • Loading branch information
mitchellh authored Dec 27, 2024
2 parents 67184f8 + 7e2a679 commit 2e8fb76
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 4 deletions.
4 changes: 2 additions & 2 deletions app/features/__init__.py
Original file line number Diff line number Diff line change
@@ -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")
File renamed without changes.
2 changes: 1 addition & 1 deletion app/view/__init__.py
Original file line number Diff line number Diff line change
@@ -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")
31 changes: 30 additions & 1 deletion app/view/mod.py → app/view/move_message.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from typing import cast

import discord

from app.setup import bot
Expand Down Expand Up @@ -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
)

0 comments on commit 2e8fb76

Please sign in to comment.