Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/astrxnomo/discord-ticket-bot-py/llms.txt

Use this file to discover all available pages before exploring further.

The Discord Ticket Bot creates and deletes channels, sends embeds, pings roles, and manages per-channel permission overrides on the fly. For all of this to work correctly, the bot’s own role must be granted a specific set of permissions in your server. Granting too few permissions causes silent failures — channels won’t be created, staff won’t be pinged, or logs won’t be posted.

Bot Permissions Required

Grant these permissions to the bot’s role in Server Settings → Roles:
PermissionWhy it’s needed
Manage ChannelsCreates a new text channel per ticket and deletes it when the ticket is closed
Send MessagesPosts embeds, button messages, and notifications in ticket channels and the log channel
Read Messages / View ChannelsReads messages and sees channels so event handlers can access interaction.channel
Embed LinksSends rich embeds for the ticket panel, welcome messages, staff pings, and ticket logs
Attach Files(Optional) Allows staff and users to share screenshots and files inside ticket channels
Read Message HistoryReads existing messages in ticket channels so the bot can respond in context
Manage MessagesDeletes the tb!ticket invoking message and removes close-confirmation messages on demand
Add ReactionsAllows the bot and users to add reactions inside ticket channels
Mention @everyone, @here, and All RolesPings the staff role (<@&id_staff_role>) when the 🔔 Call staff button is pressed

Channel-Level Permission Overrides

When a ticket channel is created, on_select_option applies three explicit permission overrides to that specific channel. These overrides are set programmatically via channel.set_permissions(...):

@everyone (the default role)

Hides the ticket channel from everyone who is not explicitly granted access.
PermissionValue
send_messagesFalse
read_messagesFalse

Ticket creator

Gives the person who opened the ticket full access to their private channel.
PermissionValue
read_messagesTrue
send_messagesTrue
add_reactionsTrue
embed_linksTrue
attach_filesTrue
read_message_historyTrue
external_emojisTrue

Staff role

Grants staff members the same access as the ticket creator, plus the ability to delete messages in the ticket channel.
PermissionValue
read_messagesTrue
send_messagesTrue
add_reactionsTrue
embed_linksTrue
attach_filesTrue
read_message_historyTrue
external_emojisTrue
manage_messagesTrue

Command Permission

The tb!ticket text command is protected by the @commands.has_permissions(administrator=True) decorator. Any user who does not hold the Administrator permission in the server will receive no response when invoking the command — it is silently ignored.
@bot.command()
@commands.has_permissions(administrator=True)
async def ticket(ctx):
    await ctx.message.delete()
    embed = discord.Embed(
        title='Tickets',
        description='Welcome to tickets system.',
        color=embed_color
    )
    embed.set_image(url='https://i.imgur.com/FoI5ITb.png')
    await ctx.send(
        embed=embed,
        components=[
            Button(custom_id='Ticket', label="Create a ticket",
                   style=ButtonStyle.green, emoji='🔧')
        ]
    )
Only server administrators should need this command; it is intended to be run once (or rarely) to post the ticket panel in a designated channel.
The bot’s role must be positioned above the staff role in the server’s role hierarchy (Server Settings → Roles, drag to reorder). Discord enforces that a bot can only modify permissions for roles ranked below its own highest role. If the bot’s role is below or equal to the staff role, channel.set_permissions(rol_staff, ...) will raise a Forbidden error and the ticket channel will be created without the correct staff access.

Build docs developers (and LLMs) love