> ## Documentation Index
> Fetch the complete documentation index at: https://docs.postqueen.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Discord setup

> Register the Discord application and give PostQueen its keys

On your own instance the Discord application is yours: create it, give it a bot, then put the client id, secret and bot token in your environment.

<Steps>
  <Step title="Create a Discord Application">
    Login to Discord on the web, and then go to the [Discord Developer Portal](https://discord.com/developers/applications) and click on "New Application".

    <Frame>
      <img src="https://mintcdn.com/forceplay/Gsgj4WOu3HFxkte6/images/providers/discord/discord_create_app.png?fit=max&auto=format&n=Gsgj4WOu3HFxkte6&q=85&s=e2e3ad1f620ae5d9bcb8db859cb2c97d" alt="New Application" width="425" height="265" data-path="images/providers/discord/discord_create_app.png" />
    </Frame>
  </Step>

  <Step title="Add an App Icon">
    <Frame>
      <img src="https://mintcdn.com/forceplay/Gsgj4WOu3HFxkte6/images/providers/discord/discord_add_app_icon.png?fit=max&auto=format&n=Gsgj4WOu3HFxkte6&q=85&s=bd4db7c7226d3cf37d28dfb81b2cca5e" alt="App Icon" width="283" height="307" data-path="images/providers/discord/discord_add_app_icon.png" />
    </Frame>

    Upload the App Icon of your choice (1024x1024px max) and save your changes. If you do not do this, you will get 404 errors in logs when trying to add the Discord channel in the PostQueen web interface.
  </Step>

  <Step title="Get and set your Client ID and Client Secret">
    You can find this in the **OAuth2** section of the Discord Developer Portal.

    <Frame>
      <img src="https://mintcdn.com/forceplay/Gsgj4WOu3HFxkte6/images/providers/discord/discord_copy_keys.png?fit=max&auto=format&n=Gsgj4WOu3HFxkte6&q=85&s=a3b97c65bf7d1d8ed2a513f57132b527" alt="Copy Keys" width="833" height="336" data-path="images/providers/discord/discord_copy_keys.png" />
    </Frame>

    The authorization screen asks for three things: `identify`, `guilds` and `bot`. The first two
    are verified on connect and refused if missing. `bot` is what installs the application into
    your server, which is why the consent screen shows a server picker.

    Set these in your .env file as follows;

    ```env theme={"system"}
    DISCORD_CLIENT_ID="your_client_id"
    DISCORD_CLIENT_SECRET="your_client_secret"
    ```
  </Step>

  <Step title="Add a Redirect URI">
    <Snippet file="oauth2redirect.mdx" />

    **Your Discord OAuth2 Redirect URI:**

    * Production: `https://postqueen.example.com/integrations/social/discord`
    * Local development: `http://localhost:4200/integrations/social/discord`
    * Docker: `http://localhost:4007/integrations/social/discord`

    You can find this in the **OAuth2** section of the Discord Developer Portal.

    <Frame>
      <img src="https://mintcdn.com/forceplay/Gsgj4WOu3HFxkte6/images/providers/discord/discord_redirect_uri.png?fit=max&auto=format&n=Gsgj4WOu3HFxkte6&q=85&s=09037b6de29d7517ce4674df6f82c814" alt="Redirect URI" width="474" height="283" data-path="images/providers/discord/discord_redirect_uri.png" />
    </Frame>
  </Step>

  <Step title="Create a Bot">
    Navigate to the "Bot" section of the Discord Developer Portal. Fill out the bot details however you like, and then click "Reset Token".

    With the token that is generated, set it in your .env file as follows;

    ```env theme={"system"}
    DISCORD_BOT_TOKEN_ID="your_bot_token"
    ```

    If you do not set this, you will get 404 errors when trying to add the Discord channel in the PostQueen web interface.

    Stop PostQueen if it is running, and then start it using the .env file with the Discord details.
  </Step>

  <Step title="Add a Discord channel in the PostQueen web interface">
    Go to the PostQueen web interface, and click on the "Add Channel" button, and then select "Discord". You should be redirected to Discord to login.
  </Step>
</Steps>

<Check>
  The channel is in the left sidebar with its avatar and name. That is the whole confirmation: if it is in the list, she can post to it.
</Check>

## Next steps

<CardGroup cols={2}>
  <Card title="What she can post to Discord" icon="https://mintcdn.com/forceplay/3MbWAJB4xKJ_Rxe0/images/channels/discord.svg?fit=max&auto=format&n=3MbWAJB4xKJ_Rxe0&q=85&s=97f2d6350f01977805fb3eb364f4dc29" href="/providers/discord" width="64" height="64" data-path="images/channels/discord.svg">
    Limits, post types and settings
  </Card>

  <Card title="Configuration reference" icon="list" href="/configuration/reference">
    Every variable she reads
  </Card>

  <Card title="Connect errors" icon="plug-circle-xmark" href="/troubleshooting/oauth-connect">
    Invalid state, invalid\_grant and the rest
  </Card>

  <Card title="Another channel" icon="plug" href="/providers/overview">
    Every network, and what each one asks for
  </Card>
</CardGroup>
