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

# Discord

> Integrate Discord messaging capabilities into your application

Connect your app to Discord's messaging platform to send notifications, build chatbots, and interact with users through Discord's popular messaging service.

## Overview

<CardGroup cols={2}>
  <Card title="Create Developer Account" icon="user">
    Sign up and configure your Discord Developer Portal.
  </Card>

  <Card title="Get Bot Token" icon="key">
    Create a Discord bot and obtain your bot token.
  </Card>

  <Card title="Verify Settings" icon="gear">
    Turn on these settings to have the best experience with Discord.
  </Card>

  <Card title="Connect to Anything" icon="plug">
    Add your credentials to Anything's secrets.
  </Card>
</CardGroup>

## Account setup

<Steps>
  <Step title="Create a Discord Developer Account">
    Go to [Discord Developer Portal](https://discord.com/developers/applications) and sign up with your account.

    <img src="https://mintcdn.com/create/aZx2kzPb48ihuqEz/images/discord/signin.png?fit=max&auto=format&n=aZx2kzPb48ihuqEz&q=85&s=fb1e784829c1e4e8600f517d38e47d18" style={{ borderRadius: '0.5rem'}} width="1534" height="796" data-path="images/discord/signin.png" />
  </Step>

  <Step title="Create a New Application">
    Click "New Application" to create a new Discord application.

    <img src="https://mintcdn.com/create/FQ38N__i9RkapQvc/images/discord/newapp.png?fit=max&auto=format&n=FQ38N__i9RkapQvc&q=85&s=1f0b6a5a24e9df8acf1c95961b94d5c1" style={{ borderRadius: '0.5rem' }} width="2674" height="1460" data-path="images/discord/newapp.png" />
  </Step>
</Steps>

## Generate API credentials

<Steps>
  <Step title="Get Your Public Key and Application ID">
    1. Find your Public Key and Application ID in the General Information section.

    <img src="https://mintcdn.com/create/FQ38N__i9RkapQvc/images/discord/appid&pubkey.png?fit=max&auto=format&n=FQ38N__i9RkapQvc&q=85&s=ae6a7a516691e149e43836ed92249466" style={{ borderRadius: '0.5rem' }} width="2282" height="814" data-path="images/discord/appid&pubkey.png" />
  </Step>

  <Step title="Get Your Bot Token">
    1. In the Bot settings, click "Reset Token" to generate and copy your bot token.

    <img src="https://mintcdn.com/create/FQ38N__i9RkapQvc/images/discord/bottoken.png?fit=max&auto=format&n=FQ38N__i9RkapQvc&q=85&s=21a059679cca4086daffb6beecee6b61" style={{ borderRadius: '0.5rem' }} width="2692" height="1342" data-path="images/discord/bottoken.png" />

    <Warning>
      Keep your bot token secure - it grants full access to your bot.
    </Warning>
  </Step>

  <Step title="Get your Guild ID">
    1. Go into your settings for the main Discord messaging application.
    2. Find the advanced tab and enable developer mode.

    <img src="https://mintcdn.com/create/FQ38N__i9RkapQvc/images/discord/enabledevelopermode.png?fit=max&auto=format&n=FQ38N__i9RkapQvc&q=85&s=078f3474862646c851918054df8ff9ab" style={{ borderRadius: '0.5rem' }} width="2388" height="1262" data-path="images/discord/enabledevelopermode.png" />

    3. Right click the server icon you want your bot to join in your list of servers.
    4. Copy the Server ID.

    <img src="https://mintcdn.com/create/FQ38N__i9RkapQvc/images/discord/getserverid.png?fit=max&auto=format&n=FQ38N__i9RkapQvc&q=85&s=5634fb78375d1a1d71f25efcaa47d2d3" style={{ borderRadius: '0.5rem' }} width="616" height="1242" data-path="images/discord/getserverid.png" />

    <Tip> Guild ID is the same as Server ID. They call it Guild to make it sound cool.</Tip>
  </Step>
</Steps>

## Verify settings

<Steps>
  <Step title="Set Bot Interactions">
    1. Head back to the Discord Developer portal and into the Bot section to enable Public Bot to allow others to download your bot.
    2. Enable Server Members intent to allow interactions with the server members.
    3. Enable Message Intent to allow the bot to interact with messages in the server.

    <img src="https://mintcdn.com/create/FQ38N__i9RkapQvc/images/discord/moresettings.png?fit=max&auto=format&n=FQ38N__i9RkapQvc&q=85&s=f8a03cf3916e7ac372dc8bbc9c0dfe28" style={{ borderRadius: '0.5rem' }} width="2680" height="1378" data-path="images/discord/moresettings.png" />
  </Step>

  <Step title="Set Bot Permissions">
    1. Go into the Install section and scroll down to find the Default Install Settings
    2. Under Guild Install, click the drop down under scopes and add Bot to the list
    3. Under Permissions, enable Send Message and Read Message history.

    <img src="https://mintcdn.com/create/aZx2kzPb48ihuqEz/images/discord/permissions.png?fit=max&auto=format&n=aZx2kzPb48ihuqEz&q=85&s=affdd98cc2e31cba6f55ccc272547102" style={{ borderRadius: '0.5rem' }} width="2694" height="1474" data-path="images/discord/permissions.png" />

    <Tip> Add more permissions here based on your Discord bot needs.</Tip>
  </Step>

  <Step title="Set Bot Webhook URL">
    1. Revisit the General Information section and scroll down to find the Interactive Endpoint URL
    2. Copy your Anything project's base URL along with api/discord-webhook similar to the example picture.
       <Warning> Make sure your Anything project is published and available on the internet </Warning>
    3. Once you click "Save Changes", the endpoint should have verified successfully.

    <img src="https://mintcdn.com/create/FQ38N__i9RkapQvc/images/discord/interactiveendpoint.png?fit=max&auto=format&n=FQ38N__i9RkapQvc&q=85&s=e853ee45c06788f92e65e6aba26f0544" style={{ borderRadius: '0.5rem' }} width="2702" height="1484" data-path="images/discord/interactiveendpoint.png" />

    <Tip> Having issues with setup? Please reach out to the community on our [Discord](https://discord.com/invite/A4mjfuhwHj).</Tip>
  </Step>
</Steps>

## Setting slash commands

<Steps>
  <Step title="Run the Create Command function">
    1. In your Anything project, run the Create Command function in the Run Test option. This will create a /chatgpt command for your bot.
       <Tip> You may skip the inputs and click "Run Test", if you have the your secrets/credentials setup. </Tip>

    <img src="https://mintcdn.com/create/aZx2kzPb48ihuqEz/images/discord/runtest.png?fit=max&auto=format&n=aZx2kzPb48ihuqEz&q=85&s=2fd767c12773da6e6d917af31aa00b45" style={{ borderRadius: '0.5rem' }} width="1288" height="1368" data-path="images/discord/runtest.png" />
  </Step>

  <Step title="Invite Your Bot to a Server">
    1. In the installation section, scroll down to find your installation link.
    2. Copy and paste it into your browser and add your bot to your server.

    <img src="https://mintcdn.com/create/FQ38N__i9RkapQvc/images/discord/addtoserver.png?fit=max&auto=format&n=FQ38N__i9RkapQvc&q=85&s=2324d3992bf0751e6e71862d6b5331ee" style={{ borderRadius: '0.5rem' }} width="698" height="714" data-path="images/discord/addtoserver.png" />
  </Step>

  <Step title="Test Your Bot">
    Send a test message using "/chatgpt Hello!" in your Discord server to verify that your bot is online and responding.

    <img src="https://mintcdn.com/create/aZx2kzPb48ihuqEz/images/discord/testchat.png?fit=max&auto=format&n=aZx2kzPb48ihuqEz&q=85&s=6fde6a791ce135407c4374cc5f9bb696" style={{ borderRadius: '0.5rem' }} width="1426" height="160" data-path="images/discord/testchat.png" />
  </Step>
</Steps>

## Add to Anything project

<Steps>
  <Step title="Add the Integration">
    1. In your Anything project, type `/` in chat.
    2. Select "Discord" from the menu.
  </Step>

  <Step title="Add Your Credentials">
    1. Paste your Bot Token into "DISCORD\_BOT\_TOKEN".
    2. Paste your Application ID to "DISCORD\_APP\_ID".
    3. Paste your Public Key to "DISCORD\_PUBLIC\_KEY".
    4. Paste your Server ID to "DISCORD\_GUILD\_ID".

    <Tip>
      Need new credentials? Regenerate in the Discord Developer Portal.
    </Tip>
  </Step>

  <Step title="Start Building">
    Use prompts to implement Discord features:

    * `Send a welcome message using /Discord`
    * `Build a chatbot that uses /Discord for customer support`
    * `Set up a notification system with /Discord`

    <Warning>
      The Discord API has rate limits. If something fails, wait a moment and try again.
    </Warning>
  </Step>
</Steps>

<Tip>
  Discord integration complete! Use `/Discord` in chat to access messaging capabilities.
</Tip>

## Frequently asked questions

<AccordionGroup>
  <Accordion title="What is Discord API?">
    Discord API allows you to interact with Discord's messaging platform, enabling you to send messages, build bots, and manage server interactions.
  </Accordion>

  <Accordion title="Do I need a Discord Developer Account?">
    Yes, you need a Discord Developer Account to access the API and create a bot. The account is free and sufficient for testing and development.
  </Accordion>

  <Accordion title="How does the bot work?">
    The bot works by listening to events in Discord and responding to commands or messages based on your implementation.
  </Accordion>

  <Accordion title="What can I build with Discord integration?">
    You can build:

    * Chatbots for customer support
    * Notification systems for events
    * Interactive games and experiences
    * Moderation tools for server management
  </Accordion>

  <Accordion title="Are there usage limits?">
    Yes, Discord has API rate limits. Free accounts have lower limits than paid accounts. Check Discord's official documentation for current limits.
  </Accordion>

  <Accordion title="Can I test my Discord integration?">
    Yes, you can test your integration by sending messages to your bot in a server where it has been invited. Monitor the bot's responses to ensure it functions as expected.
  </Accordion>
</AccordionGroup>
