Skip to main content

Overview

The SS Integrated Management Server requires several environment variables to connect to Discord, PostgreSQL, and configure system behavior. All configuration is done through a .env file in the application root directory.

Environment Variables

Discord Configuration

The following Discord-related variables are required for the bot to function:

DISCORD_BOT_TOKEN

DISCORD_BOT_TOKEN
string
required
The authentication token for your Discord bot application.
How to obtain:
1

Create Discord Application

Navigate to the Discord Developer Portal and click “New Application”.
2

Create Bot User

Go to the “Bot” section in the left sidebar and click “Add Bot”.
3

Copy Token

Under the bot’s username, click “Reset Token” and copy the generated token.
Never share your bot token publicly. Treat it like a password. If exposed, regenerate it immediately from the Discord Developer Portal.
4

Enable Intents

Enable the following Privileged Gateway Intents:
  • Server Members Intent
  • Message Content Intent

DISCORD_GUILD_ID

DISCORD_GUILD_ID
string
required
The ID of the Discord server (guild) where your tournament is taking place.
How to obtain:
1

Enable Developer Mode

In Discord, go to User Settings > App Settings > Advanced and enable “Developer Mode”.
2

Copy Server ID

Right-click on your server icon in the server list and select “Copy Server ID”.

DISCORD_MATCHES_CHANNEL_ID

DISCORD_MATCHES_CHANNEL_ID
string
required
The ID of the Discord channel where match threads will be created for live match logs and communication.
How to obtain: With Developer Mode enabled, right-click the channel name and select “Copy Channel ID”.

DISCORD_REFEREE_ROLE_ID

DISCORD_REFEREE_ROLE_ID
string
required
The ID of the Discord role assigned to tournament referees. This role will be pinged during !panic events and grants access to referee commands.
How to obtain:
1

Access Server Settings

Right-click your server icon and select “Server Settings” > “Roles”.
2

Copy Role ID

Right-click the referee role and select “Copy Role ID”.

DISCORD_ADMIN_ROLE_ID

DISCORD_ADMIN_ROLE_ID
string
required
The ID of the Discord role assigned to tournament administrators. This role has access to privileged commands like /stats.
Obtain this the same way as DISCORD_REFEREE_ROLE_ID.

Database Configuration

POSTGRESQL_CONNECTION_STRING

POSTGRESQL_CONNECTION_STRING
string
required
The connection string for your PostgreSQL database (v13+).
Format:
Host=<hostname>;Database=<database_name>;Username=<username>;Password=<password>;Port=<port>
Examples:
POSTGRESQL_CONNECTION_STRING=Host=localhost;Database=ss26db;Username=ss;Password=ss;Port=5432
Ensure your PostgreSQL server is running and accessible from the application host. The database must already exist before starting the application.

Localization Configuration

LANGUAGE

LANGUAGE
string
default:"en"
Sets the language used during automated matches and system messages.
Supported values:
  • en - English
  • es - Spanish (Español)

Creating the .env File

1

Copy the example file

From the application root directory:
cp .env.example .env
2

Edit the .env file

Open .env in your preferred text editor and fill in all required values:
.env
DISCORD_BOT_TOKEN=MTIzNDU2Nzg5MDEyMzQ1Njc4OQ.GhIjKl.MnOpQrStUvWxYzAbCdEfGhIjKlMnOpQrStUv
DISCORD_MATCHES_CHANNEL_ID=1234567890123456789
DISCORD_REFEREE_ROLE_ID=1234567890123456789
DISCORD_ADMIN_ROLE_ID=1234567890123456789
DISCORD_GUILD_ID=1234567890123456789

POSTGRESQL_CONNECTION_STRING=Host=localhost;Database=ss26db;Username=ss;Password=ss;Port=5432

LANGUAGE=en
3

Verify configuration

Ensure all Discord IDs are numeric strings (18-20 digits) and the PostgreSQL connection string is valid.

Security Best Practices

  • Never commit .env files to version control
  • Use strong, unique passwords for PostgreSQL
  • Regenerate Discord bot tokens if exposed
  • Restrict database access to the application server only
  • Use environment-specific .env files (.env.development, .env.production)

Verification

After configuring your environment variables, test the configuration:
dotnet run
The application should:
  1. Connect to PostgreSQL without errors
  2. Display “Logged in as [BotName]#[Discriminator]” in the console
  3. Show the bot as online in your Discord server
If you encounter connection errors, verify:
  • All IDs are correct and properly copied
  • The bot has been invited to your server with appropriate permissions
  • PostgreSQL is running and accessible
  • The database specified in the connection string exists

Build docs developers (and LLMs) love