tamarok
tamarok
DIdiscord.js - Imagine ❄
Created by tamarok on 1/18/2025 in #djs-questions
Listing entries in a ForumChannel?
I am wanting to list entries in a ForumChannel, but I am not sure how to go about it? I have a topic with two forum threads (if that is the right terminology?), but the following code returns 0:
async function listForumThreads (channelId: string, since?: Date) {
const client = await getClient();
const channel = client.channels.cache.get(channelId) as Channel;

if (channel?.type === ChannelType.GuildForum) {
console.log('Channel:', channel.name);
console.log('Topic:', channel.topic);
const channelForum = channel as ForumChannel;
const fetchedThreads = await channelForum.threads.fetch(undefined, { cache: false });

let idx = 0;
console.log('XX', fetchedThreads.threads.entries.length);
fetchedThreads.threads.forEach(message => {;
console.log(idx++, message.toJSON());
});
}

process.exit(1);
}
async function listForumThreads (channelId: string, since?: Date) {
const client = await getClient();
const channel = client.channels.cache.get(channelId) as Channel;

if (channel?.type === ChannelType.GuildForum) {
console.log('Channel:', channel.name);
console.log('Topic:', channel.topic);
const channelForum = channel as ForumChannel;
const fetchedThreads = await channelForum.threads.fetch(undefined, { cache: false });

let idx = 0;
console.log('XX', fetchedThreads.threads.entries.length);
fetchedThreads.threads.forEach(message => {;
console.log(idx++, message.toJSON());
});
}

process.exit(1);
}
I am trying to list the threads in a ForumChannel, their details and messages, but I am not sure how to go about his? - Discord.js 14.17.3 - Node v22.13.0
6 replies
DIdiscord.js - Imagine ❄
Created by tamarok on 10/6/2023 in #djs-questions
Processing message before notification?
Is there a way to ensure a message is processed before a notification is sent to the channel participants? We are wanting to implement a bot that will react and block messages, but on certain criteria, but if blocked we don’t want users to have been notified by the blocked message.
5 replies