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:
|
|
|
|
await interaction.user.send(f"Confirmed '{self.content.value}'")
|
|
|
|
|
|
|
|
|
|
|
|
@discord.app_commands.command()
|
|
|
|
async def post(interaction: discord.Interaction):
|
|
|
|
await interaction.response.send_modal(PostModal())
|