Skip to content

Standalone

This guide is written for Linux systems. The process is similar on Windows, but the commands may differ. Alternatively, you can install the bot on Windows with Docker.

Before you start, you need to make sure your system meets the requirements.

If you don't have a suitable version of Node.js (you can check with node -v) and a database installed, these community guides may help.

  • Node.js installation


    How to install Node.js on various operating systems and distributions.

    DigitalOcean Community

  • MySQL installation


    How to install and securely set up MySQL on various Linux distributions.

    DigitalOcean Community

Installation

Start by cloning the most recent release from GitHub with the following command, where <tag> is the name of the latest release tag, which you can find at the top right corner of this page, or on the releases page.

By default, this will clone the repository into a folder called bot, but you can change this by adding a folder name after the URL.

git clone --depth 1 --branch <tag>(1) https://github.com/discord-tickets/bot.git
  1. Replace <tag> with the latest release tag name, e.g. v4.0.0

    Example

    git clone --depth 1 --branch v4.0.0 https://github.com/discord-tickets/bot.git tickets
    

Tip

pnpm is a faster alternative to npm. You can install it with npm i -g pnpm, and then use pnpm instead of npm.

Next, install the dependencies with:

npm i --production
pnpm i --prod

NPM is configured to run scripts before and after installation.

  • The pre-install script generates a random encryption key and then creates a .env file
  • The post-install script prepares the database, but it won't do anything the first time as you need to tell it which database to use

Environment variables

Using the .env file is the recommended way to set environment variables.

Creating the Discord application

Warning

Don't skip this section if you already know how to create a Discord application; Discord Tickets requires additional configuration. Using an existing application is not recommended.

  1. Go to the Discord Developer Portal

  2. Create an application

    1. Click the New Application button
    2. Give your application a name, accept the terms of service and click Create

    Screenshot 3. Add a logo, description, and links to your terms of service and privacy policy, then click Save Changes.

    Screenshot 4. Go to the OAuth2 page and click Reset Secret, then Yes, do it!. Copy the new secret and set it as your DISCORD_SECRET environment variable.

    Screenshot 5. Click Add Redirect and enter the value of your HTTP_EXTERNAL environment variable, followed by /auth/callback. Then click Save Changes.

    Examples

    • http://12.345.67.89:8080/auth/callback
    • https://tickets.example.com/auth/callback

    If you set this to https://tickets.example.com/auth/callback, your HTTP_EXTERNAL environment variable must be set to https://tickets.example.com (without a trailing /).

    Screenshot 6. Create the bot user

    1. Go to the Bot page and click Add Bot, then Yes, do it!
    2. Click View Token, then copy the token and set it as your DISCORD_TOKEN environment variable.

    Screenshot 7. Configure the bot

    1. Optionally, disable the "public bot" option to prevent other people from adding your bot to their servers.
    2. Enable the presence, server members and message content intents.

    Screenshot

Don't add the bot to your Discord server yet; you'll do that later.

Other environment variables

The only other required non-default environment variables are DB_PROVIDER, and DB_CONNECTION_URL if you are not using SQLite as your database.


Tip

You can middle-click on links to open them in a new tab so you can easily come back to the documentation!

Refer to the configuration documentation for more information about the available environment variables, and return to this page when you have finished.

Environment variables


After setting the required environment variables, run the post-install script again:

npm run postinstall
pnpm run postinstall

This will connect to the database (or create it if using SQLite) and apply migrations to create the tables according to the schema. It will also generate the Prisma ORM client.

Starting the bot

You can now start the bot with:

node .(1)
  1. You might have noticed that there isn't an index.js file at the root of the repository. This command works because the main field in the package.json file is set to src/, so node . can be used to start Node.js with src/index.js as the entrypoint.

The first time you start the bot, it will copy the default configuration into user/config.yml.

If you want to customise your bot's status/activities, refer to the configuration guide. You will need to restart the bot for the changes to take effect. (1)

  1. Type exit or press Ctrl+C to stop the process.

Daemonising

Currently, the process will end when you close the terminal (or disconnect your SSH session). To run the bot in the background, you can turn it into a service with systemd, screen, pm2 etc.

PM2

PM2 is a process manager made for Node.js applications and is the easiest option.

Install PM2 and then start the bot with:

npm i -g pm2
pnpm add -g pm2
pm2 start .(1)
  1. You can give the process a custom name with the --name flag.

    Example

    pm2 start . --name tickets
    

Refer to the PM2 documentation for more information.

Publishing the commands

Type commands publish into the bot's console to publish the commands to Discord.

Reverse proxy

If you have a domain name, you should set up a reverse proxy with SSL/TLS and set the HTTP_TRUST_PROXY environment variable to true.

Next steps

If your bot is running, congratulations, you have successfully installed Discord Tickets, and now it's time to set it up in your Discord server.

Join the community on Discord and get notified when updates (with new features and fixes) are released.

Refer to the configuration guide for a step-by-step guide on how to add and configure the bot in your server.

Configuration

Having trouble?

If you haven't got the bot running yet and need help, you can ask for help on Discord or on GitHub.

Comments