# How to Create a Discord Bot Token (/docs/discord-bots/create-bot-token)



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

Before you can host your Discord bot on XGamingServer, you need to create a bot application on Discord and generate a token. The token is what allows your bot to log in to Discord.

> ⚠️ **Warning:** Never share your bot token publicly. Anyone with your token can control your bot. If your token is ever leaked, reset it immediately in the Developer Portal.

Creating Your Bot Application [#creating-your-bot-application]

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

    Go to [https://discord.com/developers/applications](https://discord.com/developers/applications) and log in with your Discord account.
  </div>

  <div className="fd-step">
    Create a new application [#2-create-a-new-application]

    Click **New Application** in the top-right corner. Give your application a name (this will be your bot's default username) and click **Create**.
  </div>

  <div className="fd-step">
    Go to the Bot section [#3-go-to-the-bot-section]

    In the left sidebar, click **Bot**.
  </div>

  <div className="fd-step">
    Generate your bot token [#4-generate-your-bot-token]

    If this is a brand-new application, you may see your token displayed once. Click **Copy** to save it.

    If the token is not shown, click **Reset Token** and confirm. Discord will generate a new token and display it. Copy it immediately.

    > ⚠️ **Warning:** You can only view your token once after generating it. If you lose it, you will need to reset it, which invalidates the old token.
  </div>

  <div className="fd-step">
    Save your token somewhere safe [#5-save-your-token-somewhere-safe]

    Paste your token into a secure location like a password manager or a private text file. You will need it when configuring your bot on the XGamingServer panel.
  </div>
</div>

Configuring Gateway Intents [#configuring-gateway-intents]

Gateway Intents control what events your bot receives from Discord. Some intents are considered "privileged" and must be manually enabled.

<div className="fd-steps">
  <div className="fd-step">
    Enable privileged intents [#6-enable-privileged-intents]

    On the **Bot** page, scroll down to **Privileged Gateway Intents** and enable the intents your bot needs:

    * **Presence Intent** -- Required if your bot tracks user online/offline status.
    * **Server Members Intent** -- Required if your bot needs to access the full member list or member join/leave events.
    * **Message Content Intent** -- Required if your bot reads the content of messages (needed for prefix-based commands like `!help`).

    > 💡 **Tip:** If you are unsure which intents your bot needs, check the bot's documentation or README. Many modern bots using slash commands do not need the Message Content Intent.

    > 📝 **Note:** Bots in 100 or more servers must be verified by Discord to use privileged intents. For most personal and small community bots, you can enable them freely.
  </div>
</div>

Inviting Your Bot to a Discord Server [#inviting-your-bot-to-a-discord-server]

<div className="fd-steps">
  <div className="fd-step">
    Go to the OAuth2 section [#7-go-to-the-oauth2-section]

    In the left sidebar, click **OAuth2**.
  </div>

  <div className="fd-step">
    Select the bot scope [#8-select-the-bot-scope]

    Under **OAuth2 URL Generator**, check the **bot** scope. If your bot uses slash commands, also check **applications.commands**.
  </div>

  <div className="fd-step">
    Select permissions [#9-select-permissions]

    A permissions panel will appear below. Select the permissions your bot needs. Common permissions include:

    * **Send Messages** -- Post messages in channels.
    * **Read Message History** -- View past messages.
    * **Manage Messages** -- Delete or pin messages.
    * **Manage Roles** -- Assign or remove roles from members.
    * **Connect / Speak** -- Join and talk in voice channels (for music bots).

    > 💡 **Tip:** Only grant the permissions your bot actually needs. You can always add more later by re-inviting the bot with an updated URL.
  </div>

  <div className="fd-step">
    Copy the invite URL [#10-copy-the-invite-url]

    Scroll down and copy the **Generated URL**.
  </div>

  <div className="fd-step">
    Invite the bot [#11-invite-the-bot]

    Open the URL in your browser. Select the Discord server you want to add the bot to, review the permissions, and click **Authorize**.

    Your bot application is now set up. The bot will appear offline in your server until you deploy and start it on XGamingServer. See our [Node.js](/docs/discord-bots/install-nodejs-bot), [Python](/docs/discord-bots/install-python-bot), or [custom bot](/docs/discord-bots/install-custom-bot) guides to get it running.
  </div>
</div>
