DiscordReader
DiscordReader is a simple data loader that reads all messages in a given Discord channel and returns them as Document objects. It uses the @discordjs/rest library to fetch the messages.
Usage
First step is to create a Discord Application and generating a bot token here.
In your Discord Application, go to the OAuth2
tab and generate an invite URL by selecting bot
and click Read Messages/View Channels
as wells as Read Message History
.
This will invite the bot with the necessary permissions to read messages.
Copy the URL in your browser and select the server you want your bot to join.
Params
DiscordReader()
discordToken?
: The Discord bot token.requestHandler?
: Optionally provide a custom request function for edge environments, e.g.fetch
. See discord.js for more info.
DiscordReader.loadData
channelIDs
: The ID(s) of discord channels as an array of strings.limit?
: Optionally limit the number of messages to readadditionalInfo?
: An optional flag to include embedded messages and attachment urls in the document.oldestFirst?
: An optional flag to return the oldest messages first.
API Reference
Edit on GitHub
Last updated on