Compare commits
2 commits
ec01447440
...
59ce255fda
Author | SHA1 | Date | |
---|---|---|---|
59ce255fda | |||
f7c24ebca5 |
3 changed files with 17 additions and 19 deletions
|
@ -3,19 +3,17 @@ import logging
|
|||
import discord
|
||||
|
||||
from .commands import lsstuff
|
||||
from .post import post
|
||||
from .post import ev_post
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class LenaverseBot(discord.Client):
|
||||
def __init__(self) -> None:
|
||||
intents = discord.Intents.default()
|
||||
|
||||
super().__init__(intents=intents)
|
||||
super().__init__(intents=discord.Intents.default())
|
||||
|
||||
self.tree = discord.app_commands.CommandTree(self)
|
||||
self.tree.add_command(post)
|
||||
self.tree.add_command(ev_post)
|
||||
self.tree.add_command(lsstuff)
|
||||
|
||||
async def setup_hook(self):
|
||||
|
@ -23,7 +21,5 @@ class LenaverseBot(discord.Client):
|
|||
_logger.info("Commands synced")
|
||||
|
||||
async def on_ready(self) -> None:
|
||||
if self.user is None:
|
||||
return
|
||||
|
||||
assert self.user is not None
|
||||
_logger.info(f"{self.user.name} has connected to Discord!")
|
||||
|
|
|
@ -60,17 +60,23 @@ class PostModal(ui.Modal, title="Post verfassen"):
|
|||
post_content = f"{self.content.value}\n> Gepostet von <@{interaction.user.id}>"
|
||||
|
||||
# Vorschau mit Buttons
|
||||
view = PostConfirm()
|
||||
await interaction.response.send_message(
|
||||
content=f"## Post-Vorschau\n\n{post_content}",
|
||||
view=(view := PostConfirm()),
|
||||
view=view,
|
||||
# nur für ausführenden User
|
||||
ephemeral=True,
|
||||
)
|
||||
|
||||
# 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
|
||||
_logger.info(
|
||||
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)
|
||||
|
||||
elif view.action is Action.ABORT:
|
||||
# Post abbrechen
|
||||
_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()
|
||||
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)
|
||||
"""
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
[tool.poetry]
|
||||
authors = ["Jörn-Michael Miehe <joern-michael.miehe@lenaisten.de>"]
|
||||
description = ""
|
||||
name = "lenaverse-bot"
|
||||
name = "lenaverse_bot"
|
||||
readme = "README.md"
|
||||
version = "0.1.0"
|
||||
|
||||
[tool.poetry.dependencies]
|
||||
discord-py = "^2.3.2"
|
||||
python = "^3.11"
|
||||
pydantic = "^2.5.1"
|
||||
python = "^3.11"
|
||||
|
||||
[tool.poetry.group.dev.dependencies]
|
||||
black = "^23.11.0"
|
||||
|
|
Loading…
Reference in a new issue