Thread .fetchArchived() doesn't return all the archived threads even if those are public

Hey there, I'm using the .fetchArchived() function to get all the archived threads in a forum but it looks like the function returns only a limited number of results.

I had a look at the documentation but from my understanding adding the option fetchAll can be used only if the type is set to private which is not my case as all the threads are public. As you can see in the code I also didn't set a specific limit because I want to export all the archived threads but it looks like I can only get 50 of them.

async execute(interaction) {
    await interaction.deferReply({ ephemeral: true });

    const guild = interaction.guild;
    
    try {
        const inputChannel = await interaction.options.getChannel('channel');
        // Get the active threads
        let channel = await inputChannel.threads.fetch();
        // Get the archived threads
        let archived = await inputChannel.threads.fetchArchived();

        let posts = [];
        
        archived.threads.forEach(async post => {
            posts.push(post);
        })

        console.log(posts.length);
    }
    catch(e) {
        console.log(e);
        await interaction.editReply({content: `Something went wrong while processing the interaction`});
    }
}
Was this page helpful?