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`});
}
}
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`});
}
}
2 Replies
d.js toolkit
d.js toolkit3w ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by OP
fedpep
fedpepOP3w ago
Thanks, after some tests I discovered that the .fetchArchived() by default gives only 50 results. Should this be added to the official documentation? Asking this because the .fetch function seems not limited
Want results from more Discord servers?
Add your server