> ## Documentation Index
> Fetch the complete documentation index at: https://docs.razebot.tech/llms.txt
> Use this file to discover all available pages before exploring further.

# Lifecycle

> How tickets open, get claimed, close, and are deleted — plus inactivity automation.

# Lifecycle

> How tickets open, get claimed, close, and are deleted — plus inactivity automation.

## Ticket Flow

<Accordion title="Flowchart" icon="diagram-project">
  Full lifecycle from open to delete. Zoom in if needed.

  ```mermaid theme={null} theme={null}
  flowchart TD

      START([Member clicks panel]) --> O1

      subgraph OPEN["Open"]
          direction TB
          O1{Blacklist / limit check}
          O1 -->|Blocked| DENIED([Access denied])
          O1 -->|Pass| O2{Topics configured?}
          O2 -->|Yes| O3[Select topic from dropdown]
          O2 -->|No| O5
          O3 --> O4{Topic has form?}
          O4 -->|Yes| FORM[Fill modal form]
          O4 -->|No| O5
          FORM --> O5[Create channel in category]
          O5 --> O6[Grant creator access · assign support roles]
          O6 --> O7[Send opening message + controls]
          O7 --> O8[Assign owner role if configured]
      end

      O8 --> ACTIVE([Ticket active])

      ACTIVE --> CLAIM_IN([Staff claims])
      ACTIVE --> CLOSE_REQ([Close requested])
      ACTIVE --> CLOSE_IN([Close initiated])

      CLOSE_REQ --> CRQ{Accepted?}
      CRQ -->|Yes| CLOSE_IN
      CRQ -->|No / timeout| ACTIVE

      subgraph CLAIM["Claim"]
          direction TB
          CL1[Record claimer] --> CL2{Claim effect?}
          CL2 -->|none| CL3[No change]
          CL2 -->|hide| CL4[Remove other support access]
          CL2 -->|rename| CL5[Rename to claimed-username]
      end

      CLAIM_IN --> CL1
      CL3 & CL4 & CL5 --> CLAIMED([Ticket claimed])
      CLAIMED --> UNCLAIM_IN([Staff unclaims])
      CLAIMED --> CLOSE_IN

      subgraph UNCLAIM["Unclaim"]
          direction TB
          UC1[Clear claimer] --> UC2[Restore permissions]
      end

      UNCLAIM_IN --> UC1
      UC2 --> ACTIVE

      INACTIVE([Inactivity timer expires]) --> CLOSE_IN

      subgraph CLOSE["Close"]
          direction TB
          CLS1[Remove creator channel access] --> CLS2[Remove owner role if set]
          CLS2 --> CLS3[Move to closed category]
          CLS3 --> CLS4[Generate HTML transcript]
          CLS4 --> CLS5[Post transcript to log channel]
          CLS5 --> CLS6[DM creator with transcript link]
          CLS6 --> CLS7[Show Reopen · Delete buttons]
      end

      CLOSE_IN --> CLS1
      CLS7 --> CLOSED([Ticket closed])

      CLOSED --> REOPEN_IN([Reopen clicked])
      CLOSED --> DELETE_IN([Delete clicked])

      subgraph REOPEN["Reopen"]
          direction TB
          RO1[Restore creator access] --> RO2[Add owner role back]
          RO2 --> RO3[Move to open category]
          RO3 --> RO4[Restore control buttons]
      end

      REOPEN_IN --> RO1
      RO4 --> ACTIVE

      subgraph DELETE["Delete"]
          direction TB
          DL1[Mark deleted · log to channel] --> DL2[Delete channel after 3 s]
      end

      DELETE_IN --> DL1
      DL2 --> DELETED([Ticket deleted])
  ```
</Accordion>

## Lifecycle Actions

<AccordionGroup>
  <Accordion title="1. Open" icon="door-open">
    When a member clicks the panel:

    * **Blacklist check** — if the member is blacklisted, access is denied immediately.
    * **Limit check** — if the member is at the per-user ticket limit, opening is blocked.
    * If topics are configured, a dropdown appears to select one.
    * If the selected topic has form fields, a modal pops up before the channel is created.
    * The channel is created in the topic's category, or the global default category.
    * The creator and all support roles receive channel access.
    * The opening message is sent with **Close** and **Claim** controls.
    * If a ticket owner role is configured, it is assigned to the creator.
    * The ticket count increments if counting is enabled.
  </Accordion>

  <Accordion title="2. Claim" icon="hand-holding">
    Staff claim a ticket via `;ticket claim` or the Claim button on the opening message.

    * The claimer is recorded in the database.
    * The claim effect set on the topic determines what happens to the channel:

    | Effect   | Behaviour                                                          |
    | -------- | ------------------------------------------------------------------ |
    | `none`   | No visibility change — all support can still see the channel       |
    | `hide`   | Other support roles lose channel access — only the claimer sees it |
    | `rename` | Channel is renamed to `claimed-{username}`                         |

    * The Claim button is disabled once claimed.
    * Only the claimer or a ticket admin can unclaim.

    Configure the effect with:

    ```bash theme={null} theme={null}
    ;ticket topic claimeffect (topic) (none|hide|rename)
    ```
  </Accordion>

  <Accordion title="3. Unclaim" icon="rotate-left">
    ```bash theme={null} theme={null}
    ;ticket unclaim
    ```

    * Clears the claimer record.
    * Restores full support role visibility if the effect was `hide`.
    * Only the current claimer or a ticket admin can unclaim.
  </Accordion>

  <Accordion title="4. Close" icon="lock">
    Triggered by `;ticket close`, the Close button, or an accepted close request.

    * Creator's channel access is removed.
    * Owner role is removed from the creator if one is set.
    * Channel moves to the closed category (per-topic, then global fallback).
    * An HTML transcript is generated and uploaded.
    * Transcript link is posted to the log channel.
    * Creator receives a DM with the transcript link.
    * **Reopen** and **Delete** buttons appear on the opening message.

    Close permission is configurable per topic:

    ```bash theme={null} theme={null}
    ;ticket topic permissions (topic) (close) (delete)
    ```

    | Value      | Who can close                            |
    | ---------- | ---------------------------------------- |
    | `support`  | Ticket owner and support staff (default) |
    | `everyone` | Any member in the channel                |
    | `admin`    | Ticket admins only                       |
  </Accordion>

  <Accordion title="5. Close request" icon="circle-question">
    ```bash theme={null} theme={null}
    ;ticket closerequest
    ```

    Sends a confirmation prompt in the ticket. The ticket owner or any support member can Accept or Deny within 300 seconds.

    * **Accept** — closes the ticket via the normal close flow.
    * **Deny** — deletes the request message, ticket stays open.
    * If the view times out, the request is dismissed.
  </Accordion>

  <Accordion title="6. Reopen" icon="lock-open">
    Staff click the Reopen button on a closed ticket's message.

    * Creator's channel access is restored.
    * Owner role is reassigned if configured.
    * Channel moves back to the open category.
    * Control buttons (Close, Claim) are restored on the opening message.
  </Accordion>

  <Accordion title="7. Delete" icon="trash">
    Staff click the Delete button on a closed ticket's message.

    * Ticket is marked deleted in the database.
    * Action is logged to the log channel.
    * Channel is deleted after a 3-second delay.

    Delete permission is configurable per topic alongside close permission:

    ```bash theme={null} theme={null}
    ;ticket topic permissions (topic) (close) (delete)
    ```
  </Accordion>
</AccordionGroup>

***

## Automation

Set configuration automation at the topic level to keep channels clean.

<AccordionGroup>
  <Accordion title="Inactivity Reminder" icon="bell">
    If configured on the topic:

    * The system tracks the creator's last message.
    * If they go quiet long enough, it sends the inactivity reminder.
    * If they reply again, the timer resets.

    ```bash theme={null} theme={null}
    ;ticket topic inactivity reminder (topic) (hours)
    ```
  </Accordion>

  <Accordion title="Auto-Close" icon="clock">
    If configured on the topic:

    * The system tracks the same creator activity window.
    * If the creator stays inactive long enough, the ticket closes automatically.
    * The auto-close message is sent when that timer triggers.

    ```bash theme={null} theme={null}
    ;ticket settings inactivity (hours)
    ```

    The system checks every 5 minutes. Set to `0` to disable. Run without arguments to view the current setting. The auto-close uses the same close flow — transcript is generated and the log channel is notified.
  </Accordion>

  <Accordion title="Auto-Delete After Close" icon="trash-clock">
    If configured on the topic:

    * Once a ticket is closed, a delete timer starts.
    * The auto-delete message is sent when that timer starts.
    * Reopening the ticket clears that timer.
    * Deleting the ticket manually clears that timer too.
    * When the timer expires, the closed ticket channel is deleted automatically.

    ```bash theme={null} theme={null}
    ;ticket topic autodelete (topic) (hours)
    ```
  </Accordion>

  <Accordion title="Close On Leave" icon="person-to-door">
    If `Close On Leave` is enabled on the topic:

    * Any still-open ticket from that topic closes automatically when the ticket creator leaves the server.
    * It uses the normal close flow instead of a special one-off shutdown path.
    * Close category moves, close rename templates, close messages, and close DMs still behave normally.
    * The recorded close reason becomes `"Ticket creator left the server."`

    ```bash theme={null} theme={null}
    ;ticket topic closeonleave (topic)
    ```
  </Accordion>
</AccordionGroup>

***

## Transcripts

Transcripts are HTML exports of the full ticket conversation.

* Generated automatically on **every close**.
* Uploaded to the transcript CDN and linked in the log channel embed.
* The creator receives a DM with a direct link to view the transcript.
* Refreshed if the same ticket is closed again after a reopen.

Configure the log channel:

```bash theme={null} theme={null}
;ticket settings logs (#channel)
```
