#Forums question

6 messages · Page 1 of 1 (latest)

lament bane
#

If i want to say check a forums channel to see if there are any existing threads with a specific title and user, how would I go about it?

This might be more of a js question possibly, because I believe it would be something similar to ForumChannel.threads.fetch(), but I don't know how to filter though the cache in this specific case

Ive tried a few things like if (!channel.threads.includes('Title') === true) return

tulip kelp
#

• What's your exact discord.js npm list discord.js and node node -v version?
• Post the full error stack trace, not just the top part!
• Show your code!
• Explain what exactly your issue is.
• Not a discord.js issue? Check out #useful-servers.

west muralBOT
#

Documentation suggestion for @lament bane:
method Collection#some()
Checks if there exists an item that passes a test. Identical in behavior to Array.some().

mellow lake
#

.fetch() returns a promise of a Collection, so resolve it, and then use this method

#

It works the same as Array.prototype.some() so if you get stuck, Google has infinite results explaining the latter

lament bane
# mellow lake It works the same as `Array.prototype.some()` so if you get stuck, Google has in...

Sorry for the late response. I've been able to use Array.some(), but now I've ran into a different issue.

        // Checks to see if there is an already existing "Error Log" thread, and posts the error
        channel.threads.fetch().then((collection: any) => {
            console.log(collection)
            if (client.user?.id !== '...') return
            const name = collection.threads.some((array: any) => {
                return array.name === '🛑 Error Log'
            })
            const user = collection.threads.some((array: any) => {
                return array.ownerId === '...'
            })
            if (name === false || (name === true && user === false)) {
                channel.threads.create({
                    name: '🛑 Error Log',
                    message: {
                        content:
                            '## ![myBots](https://cdn.discordapp.com/emojis/1001930208393314334.webp?size=128 "myBots") This channel is used to inform devs of errors with @grand spoke\n\n- Follow this channel to receive alerts',
                    },
                })
            }
        })

Now if if (name === false || (name === true && user === false)) { returns false, I would like to receive the array that makes.some() return true, if that makes sense
Is there a method that does that or would it be a completely different property?