This is a guide to self host the Tickets bot. Which was announced to sunset on the 5th of March 2025 in their support server. This guide will help you set up the bot on your own machine using Docker. This is not an official guide and I will not provide support. now also with translations into: German, and Dutch
- You must have knowledge of how to use, deploy and run containers (specifically Docker)
- You must have an idea of how to use a terminal
- You should have a basic understanding of GoLang, Rust, and Svelte
- You should have a basic understanding of how to use a database (specifically PostgreSQL)
To be completely honest, I still don't know. The image below is a rough diagram of how I think the bot works after nearly a week of tinkering with the TicketsBot codebase. The dotted boxes are the containers that I did not implement into the docker-compose.yaml
in this repository.
The image above was made using Excalidraw.
-
Open a terminal in the folder you want to install the bot in. (Or create a folder and open a terminal in that folder)
-
Clone this repository into that folder (
git clone https://github.com/DanPlayz0/ticketsbot-self-host-guide.git .
)- The
.
at the end is important as it clones the repository into the current folder
- The
-
Create an
.env
file by copying the provided.env.example
file.DISCORD_BOT_TOKEN
: your bot token (e.g.OTAyMzYyNTAxMDg4NDM2MjI0.YXdUkQ.TqZm7gNV2juZHXIvLdSvaAHKQCzLxgu9
)DISCORD_BOT_CLIENT_ID
: your bot's client ID (e.g.508391840525975553
)DISCORD_BOT_OAUTH_SECRET
: your bot's client secret (e.g.AAlRmln88YpOr8H8j1VvFuidKLJxg9rM
)DISCORD_BOT_PUBLIC_KEY
: your bot's public key (e.g.fcd10216ebbc818d7ef1408a5c3c5702225b929b53b0a265b82e82b96a9a8358
)ADMIN_USER_IDS
: a comma-separated list of user IDs (e.g.209796601357533184,585576154958921739,user_id,user_id
, a single id would be209796601357533184
)DISCORD_SUPPORT_SERVER_INVITE
: the invite link to your support server (e.g.https://discord.gg/ticketsbot
)DASHBOARD_URL
: the URL of your dashboard (e.g.http://localhost:5000
)LANDING_PAGE_URL
: the URL of your landing page (e.g.https://ticketsbot.cloud
)API_URL
: the URL of your API (e.g.http://localhost:8082
)DATABASE_HOST
: your PostgreSQL host (e.g.postgres:5432
)DATABASE_PASSWORD
: your PostgreSQL password (e.g.password
)CACHE_DATABASE_HOST
: your cache database host (e.g.postgres-cache:5432
)CACHE_DATABASE_PASSWORD
: your cache database password (e.g.password
)S3_ENDPOINT
: the endpoint of your S3 bucket (e.g.minio:9000
)S3_ACCESS
: the access key of your S3 bucket (e.g.AbCdEfFgHiJkLmNoPqRsTuVwXyZ
)S3_SECRET
: the secret key of your S3 bucket (e.g.AbCdEfFgHiJkLmNoPqRsTuVwXyZ
)ARCHIVER_AES_KEY
: your AES-128 key (e.g.randomstring
)- Bash:
openssl rand -hex 16
- NodeJS:
node -e "console.log(require('crypto').randomBytes(16).toString('hex'))"
- Bash:
ARCHIVER_ADMIN_AUTH_TOKEN
: your archiver admin auth token (e.g.randomstring
)SENTRY_DSN
: your Sentry DSN (e.g.https://[email protected]/0
)
-
Replace the placeholders in the following command and paste it at the bottom of
sql-migrations/0-init-archive.sql
. There are 2 placeholders in the command,${S3_ARCHIVE_BUCKET}
and${S3_ENDPOINT}
. Replace them with your bucket name and S3 endpoint respectively. You can also just edit thesql-migrations/0-init-archive.sql
file too, you just have to uncomment it (by removing the--
at the start of the line) and replace variables there.INSERT INTO buckets (id, endpoint_url, name, active) VALUES ('b77cc1a0-91ec-4d64-bb6d-21717737ea3c', 'https://${S3_ENDPOINT}', '${S3_ARCHIVE_BUCKET}', TRUE);
-
Run
docker compose up -d
to pull the images and start the bot. -
Configure the Discord bot. (see below)
-
Register the slash commands (see below)
As this bot is self-hosted, you will need to configure the bot yourself. Here are the steps to configure the bot:
- Go to the Discord Developer Portal
- Click on the application you created for the bot
- Set the
Interactions Endpoint URL
to${HTTP_GATEWAY}/handle/${DISCORD_BOT_CLIENT_ID}
- Replace
${HTTP_GATEWAY}
with the URL of your HTTP Gateway (e.g.https://gateway.example.com
, you must have a publicly accessible URL not localhost) - Replace
${DISCORD_BOT_CLIENT_ID}
with your bot's application/client ID (e.g.508391840525975553
)
- Replace
- Go to the OAuth2 tab
- Add the redirect URL
${DASHBOARD_URL}/callback
to the OAuth2 redirect URIs- Replace
${DASHBOARD_URL}
with the URL of your dashboard (e. g.http://localhost:5000
, make sure this matches what you set in the Setup section)
- Replace
- Go to the Bot tab
- Enable the
Server Members Intent
andMessage Content Intent
toggles
- Build the register commands cli utility using
docker build -t ticketsbot/registercommands -f commands.Dockerfile .
- Get help by running
docker run --rm ticketsbot/registercommands --help
- Get help by running
- Register the commands
- Global commands only:
docker run --rm ticketsbot/registercommands --token=your_bot_token --id=your_client_id
- Global & Admin commands by running
docker run --rm ticketsbot/registercommands --token=your_bot_token --id=your_client_id --admin-guild=your_admin_guild_id
- Global commands only:
For frequently asked questions, please refer to the FAQ document.
- #1 What can I host this on?
- #2 What are the system requirements?
- #3 Can I turn off the logging?
- #4 How do I update the bot?
- #5 How do I get rid of the
ticketsbot.net
branding? - #6 I want anyone to be able to use the dashboard, how do I do that?
- #7 This requires S3, can I host this without S3? (NOT recommended)
- #8 How do I activate premium features?
- #9 How do I run the sql commands inside the database containers?
- #10 How do I import data from ticketsbot.net?
For common issues, please refer to the Common Issues document.
- #1 There's an error. (
no active bucket
) - #2 I got an error while setting the interactions url. (
The specified interactions endpoint url could not be verified.
) - #3 Invalid OAuth2 redirect_uri
- #4 ERROR: column "last_seen" of relation does not exist
- #5 I can't login to the dashboard. Every time I try to login, it loops/redirects me back to the login page
- #6 When I run a command, I get an error
- #7 ERROR: relation "import_logs" does not exist
- #7 Failed to get import runs: An internal server error occurred
- #8 ERROR: relation "panel_here_mentions" does not exist
- #8 Error: Failed to load panels: An internal server error occurred
- #8 Ticket Panels in dashboard gives me an internal server error
- #9 Exited with code 132
- #9 CPU does not support AVX2
If you have previously setup the bot and want to update to the latest version, you will need to run the following based on when you set this up. (Sorted newest first)
- If your repo was missing
sql-migrations/4-ticket-counters.sql
, run it within thepostgres
container, see FAQ #9 for how to do this. - If your repo did not have the
sql-migrations/
folder. Pull the latest changes then make sure to update thesql-migrations/0-init-archive.sql
file with your changes from the originalinit-archive.sql
file. - If your repo did not have
delete-mentions.sql
, run it within thepostgres
container, see FAQ #9 for how to do this. - Before Guide PR#15 (aka missing
panel-here-mentions.sql
), use Common Issue #8 - Before Guide PR#14 (aka missing
init-support-import.sql
), use Common Issue #7 - Before Guide PR#9, use Common Issue #4