Self Hosting

Self Hosting

If you want to host the bot yourself, you can do so by following the instructions below.

Slashy was written with Docker in mind, and fully supports it. You can find the Dockerfile (opens in a new tab) in the repository if you'd like to build it yourself. It's also accessible on Docker Hub (opens in a new tab).

You can run it using

docker run omznc/slashy:latest

This alone will not work, however.

You need to provide the following environment variables:

  • DISCORD_TOKEN - Your Discord bot token
  • DISCORD_CLIENT_ID - Your Discord bot client ID
  • DATABASE_URL - A valid PostgreSQL connection string

Using Docker Compose

I provided a docker-compose.yml (opens in a new tab) file for you to use. This will always be the latest version of my own compose file, and will be updated as I update it. It will set up a persistent PostgreSQL database and a volume for the config file automatically. You only need to provide the DISCORD_TOKEN and DISCORD_CLIENT_ID environment variables in.

If you don't want to open GitHub, here's the file at the time of writing:

services:
    database:
        image: postgres:latest
        container_name: slashy-database
        restart: unless-stopped
        environment:
            - POSTGRES_USER=slashy
            - POSTGRES_PASSWORD=slashy
            - POSTGRES_DB=slashy
        volumes:
            - slashy-data:/var/lib/postgresql/data
        healthcheck:
            test: ["CMD-SHELL", "pg_isready -U slashy"]
            interval: 5s
            retries: 3
 
    bot:
        image: omznc/slashy:latest
        container_name: slashy-bot
        restart: unless-stopped
        environment:
            - DISCORD_TOKEN=
            - DISCORD_CLIENT_ID=
            - DATABASE_URL=postgresql://slashy:slashy@database/slashy
        volumes:
            -   slashy-config:/config
        labels:
            - "com.centurylinklabs.watchtower.enable=true"
 
        depends_on:
            database:
                condition: service_healthy
 
    # Comment out or delete this if you don't want automatic updates
    watchtower:
        image: containrrr/watchtower
        container_name: slashy-watchtower
        restart: unless-stopped
        volumes:
            - /var/run/docker.sock:/var/run/docker.sock
        environment:
            - WATCHTOWER_CLEANUP=true
            - WATCHTOWER_POLL_INTERVAL=60
            - WATCHTOWER_LABEL_ENABLE=true
        depends_on:
            bot:
                condition: service_healthy
 
volumes:
    slashy-config:
    slashy-data:

This will create 2 volumes, slashy-config and slashy-data. The config volume will store the config file, and the data volume will store the database data. This also assumes that you don't have a standalone database.

After you've set up the environment variables, you can run the bot using

docker compose up -d

I've included watchtower (opens in a new tab) to keep the bot up-to-date. If you already have your own watchtower instance, or don't want automatic updates, feel free to comment out or delete that bit.

You can ignore the TOPGG_TOKEN variable. I'd like it if you didn't list your bot on top.gg or any other bot listing site, but feel free to use it in any way that covers the license paragraph at the bottom.

Yes the licence allows you to do so, but it's just a bad move.