code: from llama_index import DiscordReader
  from llama_index import download_loader
  import os
  import nest_asyncio
  nest_asyncio.apply()
  from llama_index import ServiceContext
  import openai
  import re
  import csv
  import time
  import random
  from dotenv import load_dotenv
  import os
  from llama_index import Document
  
  load_dotenv()
  
  
  openai_api_key = os.environ.get("OPENAI_API")
  discord_key = os.environ.get("DISCORD_TOKEN")
  
  os.environ["OPENAI_API_KEY"] = openai_api_key
  openai.api_key = openai_api_key
  
  def hit_discord():
  
      DiscordReader = download_loader('DiscordReader')
      discord_token = discord_key
      channel_ids = [1088751449271447552]  # Replace with your channel_i
  
      #channel_ids = [1057178784895348746]  # Replace with your channel_id
      reader = DiscordReader(discord_token=discord_token)
      documents = reader.load_data(channel_ids=channel_ids)
      print("docs length", len(documents))
      #discord_token = os.getenv("MTA4MjQyOTk4NTQ5Njc3MjYyOA.G8r0S7.MURmKr2iUaZf6AbDot5E_Gad_10oGbrMFxFVy4")
  
      #documents = DiscordReader(discord_token="MTA4MjQyOTk4NTQ5Njc3MjYyOA.G8r0S7.MURmKr2iUaZf6AbDot5E_Gad_10oGbrMFxFVy4").load_data(channel_ids=channel_ids, limit=[10])
      service_context = ServiceContext.from_defaults(chunk_size_limit=3000)
      nodes = service_context.node_parser.get_nodes_from_documents(documents)
  
      print("nodes length:", len(nodes))
  
      questions = {}
      array_of_docs = []
      for n in nodes:
          print(n)
          prompt = f"""You are tasked with parsing out only the text from Discord messages (including who wrote it and their role). Here is the Discord data: {n}"""
  
          MAX_RETRIES = 3
          SLEEP_TIME = 0.75  # in seconds
  
          for _ in range(MAX_RETRIES):
              try:
                  time.sleep(round(random.uniform(0, SLEEP_TIME), 2))
                  completion = openai.ChatCompletion.create(
                      model="gpt-3.5-turbo",
                          messages=[
                          {"role": "user", "content": prompt}
                      ],
                      temperature=0
                  )
                  break  # If the API call works leave loop
              except Exception as e:
  
                  print(f"Error calling OpenAI API: {e}")
                  time.sleep(SLEEP_TIME)
  
  
          #print(completion.choices[0].message['content'])
          text = completion.choices[0].message['content']
          document = Document(text=text)
          array_of_docs.append(document)
      print(array_of_docs)
      return array_of_docs
  
  
  __all__ = ['hit_discord']
  
apis: llama_index.DiscordReader llama_index.ServiceContext.from_defaults llama_index.download_loader llama_index.Document
extract_api: [((108, 128), 'nest_asyncio.apply', 'nest_asyncio.apply', ([], {}), '()\n', (126, 128), False, 'import nest_asyncio\n'), ((304, 317), 'dotenv.load_dotenv', 'load_dotenv', ([], {}), '()\n', (315, 317), False, 'from dotenv import load_dotenv\n'), ((337, 365), 'os.environ.get', 'os.environ.get', (['"""OPENAI_API"""'], {}), "('OPENAI_API')\n", (351, 365), False, 'import os\n'), ((380, 411), 'os.environ.get', 'os.environ.get', (['"""DISCORD_TOKEN"""'], {}), "('DISCORD_TOKEN')\n", (394, 411), False, 'import os\n'), ((532, 564), 'llama_index.download_loader', 'download_loader', (['"""DiscordReader"""'], {}), "('DiscordReader')\n", (547, 564), False, 'from llama_index import download_loader\n'), ((755, 797), 'llama_index.DiscordReader', 'DiscordReader', ([], {'discord_token': 'discord_token'}), '(discord_token=discord_token)\n', (768, 797), False, 'from llama_index import DiscordReader\n'), ((1195, 1246), 'llama_index.ServiceContext.from_defaults', 'ServiceContext.from_defaults', ([], {'chunk_size_limit': '(3000)'}), '(chunk_size_limit=3000)\n', (1223, 1246), False, 'from llama_index import ServiceContext\n'), ((2389, 2408), 'llama_index.Document', 'Document', ([], {'text': 'text'}), '(text=text)\n', (2397, 2408), False, 'from llama_index import Document\n'), ((1823, 1941), 'openai.ChatCompletion.create', 'openai.ChatCompletion.create', ([], {'model': '"""gpt-3.5-turbo"""', 'messages': "[{'role': 'user', 'content': prompt}]", 'temperature': '(0)'}), "(model='gpt-3.5-turbo', messages=[{'role':\n    'user', 'content': prompt}], temperature=0)\n", (1851, 1941), False, 'import openai\n'), ((2232, 2254), 'time.sleep', 'time.sleep', (['SLEEP_TIME'], {}), '(SLEEP_TIME)\n', (2242, 2254), False, 'import time\n'), ((1759, 1788), 'random.uniform', 'random.uniform', (['(0)', 'SLEEP_TIME'], {}), '(0, SLEEP_TIME)\n', (1773, 1788), False, 'import random\n')]