discord.mdx 732 B

12345678910111213141516171819202122232425262728
  1. ---
  2. title: "💬 Discord"
  3. ---
  4. To add any Discord channel messages to your app, just add the `channel_id` as the source and set the `data_type` to `discord`.
  5. <Note>
  6. This loader requires a Discord bot token with read messages access.
  7. To obtain the token, follow the instructions provided in this tutorial:
  8. <a href="https://www.writebots.com/discord-bot-token/">How to Get a Discord Bot Token?</a>.
  9. </Note>
  10. ```python
  11. import os
  12. from embedchain import App
  13. # add your discord "BOT" token
  14. os.environ["DISCORD_TOKEN"] = "xxx"
  15. app = App()
  16. app.add("1177296711023075338", data_type="discord")
  17. response = app.query("What is Joe saying about Elon Musk?")
  18. print(response)
  19. # Answer: Joe is saying "Elon Musk is a genius".
  20. ```