1
0
Fork 0
mirror of https://code.lenaisten.de/Lenaisten/lenaverse-bot.git synced 2024-11-22 15:03:01 +00:00
lenaverse-bot/lenaverse_bot/core/commands.py

60 lines
1.8 KiB
Python

import discord
from discord import ui
# Define a simple View that gives us a confirmation menu
class Confirm(ui.View):
value: bool | None = None
@ui.button(label="Confirm", style=discord.ButtonStyle.green)
async def confirm(self, interaction: discord.Interaction, button: ui.Button):
await interaction.response.edit_message(content="Confirming", view=None)
self.value = True
self.stop()
@ui.button(label="Cancel", style=discord.ButtonStyle.grey)
async def cancel(self, interaction: discord.Interaction, button: ui.Button):
await interaction.response.edit_message(content="Cancelling", view=None)
self.value = False
self.stop()
class PostModal(ui.Modal, title="foobar2000"):
content = ui.TextInput(
label="Hier könnte Ihre Werbung stehen",
style=discord.TextStyle.long,
)
async def on_submit(self, interaction: discord.Interaction):
view = Confirm()
await interaction.response.send_message(
content=f"## Vorschau\n\n{self.content.value}",
view=view,
ephemeral=True,
)
await view.wait()
if view.value:
await interaction.user.send(self.content.value)
@discord.app_commands.command()
async def post(interaction: discord.Interaction):
await interaction.response.send_modal(PostModal())
@discord.app_commands.command()
async def lsstuff(interaction: discord.Interaction):
msg = ""
for guild in interaction.client.guilds:
msg += f"\n- {guild.name}"
for channel in guild.channels:
msg += f"\n - {channel.name}"
if isinstance(channel, discord.ForumChannel | discord.TextChannel):
for thread in channel.threads:
msg += f"\n - {thread.name}"
await interaction.response.send_message(msg, ephemeral=True)