2023-11-18 20:52:07 +00:00
|
|
|
import discord
|
|
|
|
from discord import ui
|
2023-11-17 10:49:50 +00:00
|
|
|
|
|
|
|
|
2023-11-18 20:52:07 +00:00
|
|
|
# Define a simple View that gives us a confirmation menu
|
|
|
|
class Confirm(ui.View):
|
|
|
|
value: bool | None = None
|
2023-11-17 10:49:50 +00:00
|
|
|
|
2023-11-18 20:52:07 +00:00
|
|
|
@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()
|
2023-11-17 10:49:50 +00:00
|
|
|
|
2023-11-18 20:52:07 +00:00
|
|
|
@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:
|
2023-11-18 21:27:30 +00:00
|
|
|
await interaction.user.send(self.content.value)
|
2023-11-18 20:52:07 +00:00
|
|
|
|
|
|
|
|
|
|
|
@discord.app_commands.command()
|
|
|
|
async def post(interaction: discord.Interaction):
|
|
|
|
await interaction.response.send_modal(PostModal())
|
2023-11-18 21:27:30 +00:00
|
|
|
|
|
|
|
|
|
|
|
@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)
|