Dokumentation / Developers / Cookbook / 11) Ticket triage: /ticket opens a thread
BuildSDK 0.10.1

11) Ticket triage: /ticket opens a thread

These docs are public. To publish a plugin you need a YourBot account: sign in to open the Dev Portal.

User runs /ticket <subject>; the bot creates a private thread and posts the details there. create_thread needs discord:manage_channels (auto-detected).

@plugin.on_slash_command("ticket")
def open_ticket(ctx: Context, event: dict):
    opts = {o["name"]: o["value"] for o in event.get("options", [])}
    subject = opts.get("subject") or "Support request"
    thread = ctx.discord.create_thread(
        channel_id=event["channel_id"],
        name=f"ticket-{event['user_id']}"[:100],
        thread_type=12,   # 12 = private thread
    )
    ctx.discord.send_message(channel_id=thread["id"],
        content=f"**Ticket from <@{event['user_id']}>**: {subject}")
    ctx.interaction.respond(content="Ticket opened. Staff will reply shortly.")
YourBot docs Reference tables are generated from the code that is running. Ask in Discord Suggest a correction