How to Set Your Discord Bot Token

Learn how to configure your Discord bot token on the XGamingServer panel so your bot can connect to Discord.

Your Discord bot token is the credential that allows your bot to log in to Discord. This guide explains how to set it in the XGamingServer panel.

⚠️ Warning: Never share your bot token publicly, commit it to a public GitHub repository, or paste it in Discord channels. Anyone with your token can control your bot.

Setting the Token via Startup Variables

The simplest way to set your bot token is through the Startup page.

Open the Startup page

Log in to the XGamingServer panel and go to the Startup page in the sidebar.

Find the token variable

Look for a variable labeled Bot Token, TOKEN, or similar. The exact name depends on how the egg was configured for your server.

Paste your token

Paste your Discord bot token into the field and save.

Restart the server

Go to the Console page and click Restart for the change to take effect.

Setting the Token via a .env File

Many bots are designed to read their token from a .env file. This is especially common for bots pulled from GitHub.

Check what variable name your bot expects

Look at the bot's source code, README, or .env.example file. Common variable names include:

  • TOKEN
  • BOT_TOKEN
  • DISCORD_TOKEN
  • DISCORD_BOT_TOKEN

Open the file manager

Go to the Files page in the panel sidebar.

Create or edit the .env file

If a .env file already exists, click on it to edit. If not, click New File, name it .env, and add your token:

TOKEN=your_token_here

Replace TOKEN with whatever variable name your bot expects, and your_token_here with your actual token.

📝 Note: Do not include quotes around the token value unless the bot's documentation specifically says to.

Save and restart

Save the file, then go to the Console page and click Restart.

Which Method Should I Use?

MethodBest For
Startup variableSimple setup, token is managed directly in the panel
.env fileBots that expect a .env file, or when you need to set multiple environment variables

Both methods work. If your bot's code uses a library like dotenv (Node.js) or python-dotenv (Python) to load environment variables, it expects a .env file. If it reads from process.env or os.environ directly, either method will work.

Resetting a Leaked Token

If your bot token was accidentally shared or exposed:

Reset the token

Go to the Bot section and click Reset Token. Confirm the reset.

Update the token on your server

Copy the new token and update it on the Startup page or in your .env file on the XGamingServer panel.

Restart the server

Go to the Console page and click Restart.

Your bot will now use the new token, and the old one will no longer work.

How is this guide?

40% Off — Limited TimeGet your Discord Bots server todayInstant setup, DDoS protection, and 24/7 support included.
Get a Server

On this page