diff --git a/lenaverse_bot/core/post.py b/lenaverse_bot/core/post.py index 2d21e4c..e88dae4 100644 --- a/lenaverse_bot/core/post.py +++ b/lenaverse_bot/core/post.py @@ -1,3 +1,4 @@ +import logging from enum import Enum, auto import discord @@ -5,6 +6,8 @@ from discord import ui from .config import CONFIG +_logger = logging.getLogger(__name__) + class Action(Enum): """ @@ -54,9 +57,11 @@ class PostModal(ui.Modal, title="Post verfassen"): ) async def on_submit(self, interaction: discord.Interaction): + post_content = f"{self.content.value}\n> Gepostet von <@{interaction.user.id}>" + await interaction.response.send_message( # Vorschau mit Buttons - content=f"## Post-Vorschau\n\n{self.content.value}", + content=f"## Post-Vorschau\n\n{post_content}", view=(view := PostConfirm()), # nur für ausführenden User ephemeral=True, @@ -67,8 +72,21 @@ class PostModal(ui.Modal, title="Post verfassen"): if view.action is Action.PUBLISH: # Post veröffentlichen + _logger.info( + f"User {interaction.user.name}({interaction.user.id}) finished a /post" + ) target = CONFIG.post.target.get(interaction.client) - await target.send(self.content.value) + await target.send(post_content) + + elif view.action is Action.ABORT: + _logger.info( + f"User {interaction.user.name}({interaction.user.id}) aborted a /post" + ) + + elif view.action is Action.TIMEOUT: + _logger.info( + f"User {interaction.user.name}({interaction.user.id}) timeout during /post" + ) @discord.app_commands.command() @@ -79,9 +97,15 @@ async def post(interaction: discord.Interaction): if interaction.user.id in CONFIG.post.users: # Verfassen-Dialog anzeigen + _logger.info( + f"User {interaction.user.name}({interaction.user.id}) started a /post" + ) await interaction.response.send_modal(PostModal()) else: + _logger.warning( + f"User {interaction.user.name}({interaction.user.id}) tried to /post" + ) await interaction.response.send_message( # Zugriff verweigern content="Du bist nicht berechtigt, den `/post`-Befehl zu benutzen!",