Ayfri / discord-fetch-messages

A npm package to fetch all of the messages of a channel, channel list or a guild, using discord.js.

Home Page:https://www.npmjs.com/package/discord-fetch-messages

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

GitHub code size in bytes npm npm Language grade: 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 ⚠️

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.

About

A npm package to fetch all of the messages of a channel, channel list or a guild, using discord.js.

https://www.npmjs.com/package/discord-fetch-messages

License:GNU General Public License v3.0


Languages

Language:TypeScript 99.6%Language:JavaScript 0.4%