discord_bot.mdx 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. ---
  2. title: '🤖 Discord Bot'
  3. ---
  4. ### 🔑 Keys Setup
  5. - Set your `OPENAI_API_KEY` in your variables.env file.
  6. - Go to [https://discord.com/developers/applications/](https://discord.com/developers/applications/) and click on `New Application`.
  7. - Enter the name for your bot, accept the terms and click on `Create`. On the resulting page, enter the details of your bot as you like.
  8. - On the left sidebar, click on `Bot`. Under the heading `Privileged Gateway Intents`, toggle all 3 options to ON position. Save your changes.
  9. - Now click on `Reset Token` and copy the token value. Set it as `DISCORD_BOT_TOKEN` in variables.env file.
  10. - On the left sidebar, click on `OAuth2` and go to `General`.
  11. - Set `Authorization Method` to `In-app Authorization`. Under `Scopes` select `bot`.
  12. - Under `Bot Permissions` allow the following and then click on `Save Changes`.
  13. ```text
  14. Read Messages/View Channel (under General Permissions)
  15. Send Messages (under Text Permissions)
  16. Read Message History (under Text Permissions)
  17. Mention everyone (under Text Permissions)
  18. ```
  19. - Now under `OAuth2` and go to `URL Generator`. Under `Scopes` select `bot`.
  20. - Under `Bot Permissions` set the same permissions as above.
  21. - Now scroll down and copy the `Generated URL`. Paste it in a browser window and select the Server where you want to add the bot.
  22. - Click on `Continue` and authorize the bot.
  23. - 🎉 The bot has been successfully added to your server.
  24. ### 🐳 Docker Setup
  25. - To setup your discord bot using docker, run the following command inside this folder using your terminal.
  26. ```bash
  27. docker-compose up --build
  28. ```
  29. 📝 Note: The build command might take a while to install all the packages depending on your system resources.
  30. ### 🚀 Usage Instructions
  31. - Go to the server where you have added your bot.
  32. - You can add data sources to the bot using the command:
  33. ```text
  34. /ec add <data_type> <url_or_text>
  35. ```
  36. - You can ask your queries from the bot using the command:
  37. ```text
  38. /ec query <question>
  39. ```
  40. 📝 Note: To use the bot privately, you can message the bot directly by right clicking the bot and selecting `Message`.
  41. 🎉 Happy Chatting! 🎉