Ticket Bot

PythonDiscord.py

Discord Ticket Bot is a self-hosted Discord bot that brings a full support-ticket system to a server with nothing but buttons and select menus — no slash-command friction, just a "Create a ticket" button that opens a private, permission-scoped channel per request.

Architecture and Tech Stack

Core Architecture

  • Language: Python
  • Framework: discord.py + the Discord Components Library for buttons and select menus
  • Configuration: four constants set directly in main/main.py — category ID, logs channel ID, staff role ID, embed color — no database, no external services
  • Structure: a single-file bot (main/main.py); everything — the ticket panel, category selection, channel creation, staff notification, and closure — lives in one place

Ticket Lifecycle

Three Discord-specific permission overwrites make each ticket channel private by construction: @everyone is denied read/send, the ticket creator gets full access, and the staff role gets creator-level access plus manage_messages. The bot's own role must outrank the staff role in Discord's hierarchy, or these overwrites fail with a Forbidden error.

Key Features

Features at a Glance

Button-Driven Ticket Creation, No Slash Commands

An admin posts the panel with tb!ticket (guarded by @commands.has_permissions(administrator=True) — anyone else gets silently ignored). A user clicks the green button, picks Question / Help / Report from a select menu, and the bot creates a private channel named {emoji}┃{username}-ticket under the configured category.

Staff Escalation Without Spamming the Channel

The "🔔 Call staff" button pings the configured staff role but auto-deletes its own message after 20 seconds — the ping does its job without leaving a permanent low-value message cluttering the ticket history.

Confirm-Before-Delete Closure

Closing a ticket doesn't delete the channel immediately — a "⚠️ Are you sure?" prompt with Yes/No buttons guards against an accidental click deleting a real conversation.

Structured Audit Log on Every Closure

Every confirmed closure posts an embed to the configured logs channel with the ticket's channel name, who closed it (mentioned), a UTC timestamp, and the closer's avatar — a permanent record survives even though the ticket channel itself is deleted.

Technical Highlights

Permission overwrites as the security model

Rather than checking permissions in code on every message, the bot sets Discord-native channel permission overwrites once at creation time — @everyone denied, creator granted, staff granted plus moderation — so channel privacy is enforced by Discord itself, not by the bot's own logic.

A documented Discord hierarchy constraint

The bot explicitly calls out that its own role must rank above the staff role, since Discord only lets a bot modify permissions for roles below its own — a platform constraint that's easy to hit silently (a Forbidden error) if missed, so it's called out directly rather than left as a surprise.

Auto-expiring notifications

The staff-call message deleting itself after 20 seconds is a small but deliberate choice: the ping needs to be seen once, not preserved — keeping the channel readable as the conversation continues.

Project Structure

discord-ticket-bot-py/
├── main/
│   └── main.py        # Entire bot: ticket panel, category select, channel creation,
│                       # permission overwrites, staff call, close confirmation, logging
├── req.txt             # Python dependencies (discord.py, Discord Components Library)
└── README.md

Impact and Scalability

  • Zero infrastructure: no database, no external service — the bot's own config constants are the entire setup
  • Discord-native privacy: ticket channels are private by construction via permission overwrites, not app-level access checks
  • Auditable by design: every closure leaves a structured log entry, even though the ticket channel itself is deleted
  • Easy to extend: a single-file bot means adding a fourth ticket category or a new button is a small, localized change

Notes

Built with Python, discord.py, and the Discord Components Library. Code is public on GitHub. For setup and command reference, see the full documentation wiki.

🖼️ IMAGE PLACEHOLDER — the ticket panel embed with the "Create a ticket" button and category select menu

🖼️ IMAGE PLACEHOLDER — an open ticket channel showing the welcome message with Close/Call staff buttons


© 2026 Felipe Giraldo