Find answers from the community

Updated 2 years ago

Hey I m trying to use the DiscordReader

At a glance

A community member is trying to use the DiscordReader and is encountering a "RuntimeError: This event loop is already running" issue. Another community member suggests using the example notebook, but the original poster says they weren't using it. The solution of using nest_asyncio.apply() seems to have worked for the original poster.

The discussion then shifts to the challenges of using async capabilities with the Discord reader, as it was designed for synchronous use. The community members discuss the possibility of adding async capabilities to the Discord reader to make it more useful for Discord bots that need to summarize channel contents.

There is also a discussion around the expiration of the Discord token, and the need to regularly run the import process to continuously load conversations into the Llama Index.

Useful resources
Hey, I'm trying to use the DiscordReader and getting "RuntimeError: This event loop is already running". Any ideas?
Attachment
image.png
1
j
r
b
17 comments
Hi @richardblythman | NapthaAI - out of curiosity is this using the example notebook? https://github.com/jerryjliu/gpt_index/blob/main/examples/data_connectors/DiscordDemo.ipynb
there's some jankiness with it since i'm basically trying to make an async library synchronous
No I wasn't actually.
nest_asyncio.apply() seems to have worked. Thanks!
great! lmk if you have any other questions
@jerryjliu0 I made a discordbot that has async methods, trying to use an on_message seems to make it quit with the nest_asyncio.apply and if I don't have that then I'll get the event loop exception, is there an easy fix?
hey @bluemagic are you using our async capabilities?
I haven't used any of llamas async capabilities yet
do you have a stack trace for the event loop exception / are you setting use_async=True anywhere?
I basically have a command to get it to read x messages eg /gptsummary 300 i don't have use_async=True anywhere
this is triggered in an async method on_message
Ooooh I see. You're using our Discord reader.

Yeah I see. Our discord reader is honestly pretty hacky (it was designed for synchronous use, and discord's api is entirely async). I'm open to adding methods on the Discord reader that would allow it to make use of native async capabilities
Ah I see yeah I wanted to make a discord bot that could summarize the contents of a channel if people didn't feel like reading all of a convo I feel like the discord reader would be more useful with async capabilities since people might want to use it with the discord api more
yeah that makes sense
you could try making an async discord reader class (or add that function to the existing discord reader)
Do I understand this correctly, that the DISCORD_TOKEN is only valid for a certain time period?
I am planning to load conversions into Llama Index continuously, so I would have to run import on regular basis to achieve that?
(I am not a dev, hence the noobie questions)
seems like it might be 24 hours https://www.remote.tools/discord/how-to-get-discord-tokens (ctrl-f for expiration)
Add a reply
Sign up and join the conversation on Discord