I've been working on a Discord bot command to fetch all of the archived threads on a server. I'm currently running into the 100 limit and am looking for a way to get around that limit.
Here's a post I made previously and was able to get up to 100 threads fetched from that.
I found this post where they made a system to fetch more than 100 messages, but I haven't been able to successfully convert that into code to fetch more than 100 threads. Unfortunately, dates and orders have been a bit inconsistent when printing threads, so getting that data has been a challenge.
Here's the code that I have so far that's only fetching 100 threads:
client.on('messageCreate', async function (message) {
if(message.content === "!test"){
const guild = client.guilds.cache.get("GUILD_ID_HERE"); // number removed for privacy reasons
var textChannels = message.guild.channels.cache.filter(c => c.type === ChannelType.GuildText);
textChannels.forEach(async (channel, limit = 500) => {
let archivedThreads = await channel.threads.fetchArchived({limit: 100});
console.log(archivedThreads);
});
}
}
In my final code, I also am printing this to a text file rather than the console, but I've left that additional code out here to keep this code more simplified for debugging.
Any ideas on how I can iterate through and print multiple sets of 100 threads at a time to bypass the limitations?