minor fixes

This commit is contained in:
Jörn-Michael Miehe 2023-11-19 23:37:51 +01:00
parent ec01447440
commit f7c24ebca5
2 changed files with 15 additions and 17 deletions

View file

@ -3,19 +3,17 @@ import logging
import discord import discord
from .commands import lsstuff from .commands import lsstuff
from .post import post from .post import ev_post
_logger = logging.getLogger(__name__) _logger = logging.getLogger(__name__)
class LenaverseBot(discord.Client): class LenaverseBot(discord.Client):
def __init__(self) -> None: def __init__(self) -> None:
intents = discord.Intents.default() super().__init__(intents=discord.Intents.default())
super().__init__(intents=intents)
self.tree = discord.app_commands.CommandTree(self) self.tree = discord.app_commands.CommandTree(self)
self.tree.add_command(post) self.tree.add_command(ev_post)
self.tree.add_command(lsstuff) self.tree.add_command(lsstuff)
async def setup_hook(self): async def setup_hook(self):
@ -23,7 +21,5 @@ class LenaverseBot(discord.Client):
_logger.info("Commands synced") _logger.info("Commands synced")
async def on_ready(self) -> None: async def on_ready(self) -> None:
if self.user is None: assert self.user is not None
return
_logger.info(f"{self.user.name} has connected to Discord!") _logger.info(f"{self.user.name} has connected to Discord!")

View file

@ -60,17 +60,23 @@ class PostModal(ui.Modal, title="Post verfassen"):
post_content = f"{self.content.value}\n> Gepostet von <@{interaction.user.id}>" post_content = f"{self.content.value}\n> Gepostet von <@{interaction.user.id}>"
# Vorschau mit Buttons # Vorschau mit Buttons
view = PostConfirm()
await interaction.response.send_message( await interaction.response.send_message(
content=f"## Post-Vorschau\n\n{post_content}", content=f"## Post-Vorschau\n\n{post_content}",
view=(view := PostConfirm()), view=view,
# nur für ausführenden User # nur für ausführenden User
ephemeral=True, ephemeral=True,
) )
# warten auf User-Entscheidung # warten auf User-Entscheidung
await view.wait() if await view.wait() is True:
# Entscheidungszeit abgelaufen
await interaction.user.send("Zeit abgelaufen, Post verworfen ")
_logger.info(
f"User {interaction.user.name}({interaction.user.id}) timeout during /post"
)
if view.action is Action.PUBLISH: elif view.action is Action.PUBLISH:
# Post veröffentlichen # Post veröffentlichen
_logger.info( _logger.info(
f"User {interaction.user.name}({interaction.user.id}) published a /post" f"User {interaction.user.name}({interaction.user.id}) published a /post"
@ -79,18 +85,14 @@ class PostModal(ui.Modal, title="Post verfassen"):
await target.send(post_content) await target.send(post_content)
elif view.action is Action.ABORT: elif view.action is Action.ABORT:
# Post abbrechen
_logger.info( _logger.info(
f"User {interaction.user.name}({interaction.user.id}) aborted a /post" 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() @discord.app_commands.command()
async def post(interaction: discord.Interaction): async def ev_post(interaction: discord.Interaction) -> None:
""" """
Einen Post im Lenaisten-Bereich verfassen (nur für ausgewählte Mitglieder verfügbar) Einen Post im Lenaisten-Bereich verfassen (nur für ausgewählte Mitglieder verfügbar)
""" """