Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ayfri/discord-fetch-messages
A npm package to fetch all of the messages of a channel, channel list or a guild, using discord.js.
https://github.com/ayfri/discord-fetch-messages
discord discord-bot discord-js discord-messages fetch fetching
Last synced: 10 days ago
JSON representation
A npm package to fetch all of the messages of a channel, channel list or a guild, using discord.js.
- Host: GitHub
- URL: https://github.com/ayfri/discord-fetch-messages
- Owner: Ayfri
- License: gpl-3.0
- Created: 2020-10-20T20:55:40.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2023-06-02T11:57:23.000Z (over 1 year ago)
- Last Synced: 2024-10-12T09:22:47.888Z (26 days ago)
- Topics: discord, discord-bot, discord-js, discord-messages, fetch, fetching
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/discord-fetch-messages
- Size: 83 KB
- Stars: 12
- Watchers: 2
- Forks: 2
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/Ayfri/discord-fetch-messages)
![npm](https://img.shields.io/npm/dt/discord-fetch-messages)
![npm](https://img.shields.io/npm/v/discord-fetch-messages?label=latest%20version)
[![Language grade: JavaScript](https://img.shields.io/lgtm/grade/javascript/g/Ayfri/discord-fetch-messages.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/Ayfri/discord-fetch-messages/context:javascript)# discord-fetch
A npm package to fetch all the messages from a guild, a channel or a thread.
## How to use it
⚠️ READ BEFORE USING ⚠️
These operations took a long time to process. Be patient and avoid doing this often because it's doing a lot of requests to Discord and you can be banned for sending too many requests to Discord.
⚠️ READ BEFORE USING ⚠️```js
const fetcher = new Fetcher(client);fetcher.on('fetchChannel', async channel => {
await message.channel.send(`Fetching <#${channel.id}>.`);
});const guildMessages = await fetcher.fetchGuild(guildID);
const channelMessages = await fetcher.fetchChannel(channel);
const threadMessages = await fetcher.fetchThread(thread);const channelsMessages = await fetcher.fetchChannels(
guild.channels.filter(channel => channel.isText() && !channel.isThread() && channel.name.startsWith('g'))
);
const guildMessagesAndThreads = await fetcher.fetchGuild(guildID, true);const threadsMessages = await fetcher.fetchThreads(threadsIDs, parentChannelOfThreads);
```## Event list :
| Event Name | Description | Arguments |
| -------------- | ------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------ |
| `fetchChannel` | Emitter when fetching a Channel. | `channel`: The channel fetched. |
| `fetchGuild` | Emitted when fetching a Guild. | `guild`: The guild fetched. |
| `fetch` | Emitted after fetched a bulk a of messages, can fetch 0 to 100 messages. | `length`: The number of messages fetched.
`messages`: The messages fetched, as a Collection. |
| `fetchThread` | Emitted when fetching a Thread. | `thread`: The thread fetched.
`channel`: The parent channel of the thread. |You can also use a `fetching` boolean property that is set to true when fetching a bulk of message, then to false.
> Note :
>
> Node.js > 16 is required.