#How to get all thread of ForumChannel

1 messages · Page 1 of 1 (latest)

neat flower
#

I try to get all thread but my loop return only open thread and I want open and archived

@bot.slash_command(name="stats", description="Affiche les statistiques du bot")
async def stats(ctx):
    if not ctx.author.guild_permissions.manage_messages:
        return await ctx.respond(embed=discord.Embed(description="**`❌` Vous n'avez pas la permission d'utiliser cette commande.**"))
    embed = discord.Embed()
    guild = bot.get_guild(1169680945016750160)
    channel = await guild.fetch_channel(1282319427815346278)
    if not channel or isinstance(channel, discord.StageChannel):
        return
    post_open = 0
    post_closed = 0
    
    for post in channel.threads:
        print(post.id)
        post = guild.get_thread(post.id)
        if post.locked or post.archived: 
            post_closed += 1
        else:
            post_open += 1
        
    embed.title = "Statistiques du support"
    embed.description = f"""**🔓 Poste ouvert**: {post_open}\n\n**🔒 Poste fermé**: {post_closed}"""
    await ctx.respond(embed=embed)
fast sedge
neat flower
#

Ok tysm

fast sedge
#

there should probably be a get_threads function that has options to return either archived, open, or all thread imo

loud forum
severe radish
#

when guilds are received through the gateway, it only includes data for active threads

#

(this also goes for events like THREAD_LIST_SYNC, which is whenever the user gains access to a channel)