Open In Colab

Discord Reader#

Demonstrates our Discord data connector

If you’re opening this Notebook on colab, you will probably need to install LlamaIndex 🦙.

%pip install llama-index-readers-discord
!pip install llama-index
import logging
import sys

logging.basicConfig(stream=sys.stdout, level=logging.INFO)
# This is due to the fact that we use asyncio.loop_until_complete in
# the DiscordReader. Since the Jupyter kernel itself runs on
# an event loop, we need to add some help with nesting
!pip install nest_asyncio
import nest_asyncio

from llama_index.core import SummaryIndex
from llama_index.readers.discord import DiscordReader
from IPython.display import Markdown, display
import os
discord_token = os.getenv("DISCORD_TOKEN")
channel_ids = [1057178784895348746]  # Replace with your channel_id
documents = DiscordReader(discord_token=discord_token).load_data(
index = SummaryIndex.from_documents(documents)
# set Logging to DEBUG for more detailed outputs
query_engine = index.as_query_engine()
response = query_engine.query("<query_text>")