I'm working on a Discord bot that can fetch archived threads from various channels on my Discord server. Right now I have the code working where it will fetch the data from the current channel that the message is sent in, but I'm looking for a way to fetch thread data from all channels on the server (or at least allow me to specify which channel to print that data from so I can run all of my commands in my bot channel).
I'm on Discord.js version 14.1.2.
This is what I have so far:
client.on('messageCreate', async function (message) {
if (message.content === "!test"){
const guild = client.guilds.cache.get("GUILD_ID_HERE"); // This has been removed here for privacy
let archivedThreads = await message.channel.threads.fetchArchived()
console.log(archivedThreads)
}
}
I believe the reason it's only printing the current channel is because of the message.
part of the code, but I haven't figured out a way to access archived threads without using that code.
Any ideas on how I can fetch thread data from all of the channels on the server?