# How to Set Your Discord Bot Token (/docs/discord-bots/manage-bot-token)



import { Step, Steps } from 'fumadocs-ui/components/steps';

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 [#setting-the-token-via-startup-variables]

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

<div className="fd-steps">
  <div className="fd-step">
    Open the Startup page [#1-open-the-startup-page]

    Log in to the [XGamingServer panel](https://panel.xgamingserver.com) and go to the `Startup` page in the sidebar.
  </div>

  <div className="fd-step">
    Find the token variable [#2-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.
  </div>

  <div className="fd-step">
    Paste your token [#3-paste-your-token]

    Paste your Discord bot token into the field and save.
  </div>

  <div className="fd-step">
    Restart the server [#4-restart-the-server]

    Go to the `Console` page and click **Restart** for the change to take effect.
  </div>
</div>

Setting the Token via a .env File [#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.

<div className="fd-steps">
  <div className="fd-step">
    Check what variable name your bot expects [#1-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`
  </div>

  <div className="fd-step">
    Open the file manager [#2-open-the-file-manager]

    Go to the `Files` page in the panel sidebar.
  </div>

  <div className="fd-step">
    Create or edit the .env file [#3-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.
  </div>

  <div className="fd-step">
    Save and restart [#4-save-and-restart]

    Save the file, then go to the `Console` page and click **Restart**.
  </div>
</div>

Which Method Should I Use? [#which-method-should-i-use]

| Method           | Best For                                                                               |
| ---------------- | -------------------------------------------------------------------------------------- |
| Startup variable | Simple setup, token is managed directly in the panel                                   |
| .env file        | Bots 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 [#resetting-a-leaked-token]

If your bot token was accidentally shared or exposed:

<div className="fd-steps">
  <div className="fd-step">
    Go to the Discord Developer Portal [#1-go-to-the-discord-developer-portal]

    Open [https://discord.com/developers/applications](https://discord.com/developers/applications) and select your application.
  </div>

  <div className="fd-step">
    Reset the token [#2-reset-the-token]

    Go to the **Bot** section and click **Reset Token**. Confirm the reset.
  </div>

  <div className="fd-step">
    Update the token on your server [#3-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.
  </div>

  <div className="fd-step">
    Restart the server [#4-restart-the-server-1]

    Go to the `Console` page and click **Restart**.

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