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);
}


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
Was this page helpful?