how would i check if a certain post in a forum has a certain label and then close that post if it do

^
9 Replies
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
d.js docs
d.js docs2y ago
property ThreadChannel#appliedTags The tags applied to this thread
JollyJohn
JollyJohnOP2y ago
ok, do i need to check if the channel is a forum channel? and how do i close it
TypeError: activeThreads.forEach is not a function
TypeError: activeThreads.forEach is not a function
const threadchl = client.channels.cache.get('1090040369112170546');
console.log(threadchl)
const guild = client.guilds.cache.get('1062425704966406264');
let activeThreads = await threadchl.threads.fetchActive()
activeThreads.forEach(async (thread) => {
if (thread.appliedTags === 't') {
await thread.setArchived(true)
}
const threadchl = client.channels.cache.get('1090040369112170546');
console.log(threadchl)
const guild = client.guilds.cache.get('1062425704966406264');
let activeThreads = await threadchl.threads.fetchActive()
activeThreads.forEach(async (thread) => {
if (thread.appliedTags === 't') {
await thread.setArchived(true)
}
thats code
d.js docs
d.js docs2y ago
method GuildForumThreadManager#fetchActive() Obtains all active thread channels in the guild. This internally calls GuildChannelManager#fetchActiveThreads().
JollyJohn
JollyJohnOP2y ago
wdym .threads.forEach unstead of active Threads? ok thanks
module.exports = {
name: "threadUpdate",
once: false,

async execute(oldThread, newThread, client) {
const threadchl = client.channels.cache.get('1090040369112170546');
let activeThreads = await threadchl.threads.fetchActive()
activeThreads.threads.forEach(async (thread) => {
if (thread.appliedTags === 't') {
await thread.setArchived(true)
}
})
}
}
module.exports = {
name: "threadUpdate",
once: false,

async execute(oldThread, newThread, client) {
const threadchl = client.channels.cache.get('1090040369112170546');
let activeThreads = await threadchl.threads.fetchActive()
activeThreads.threads.forEach(async (thread) => {
if (thread.appliedTags === 't') {
await thread.setArchived(true)
}
})
}
}
got this, nothing is happening when i add the tag
d.js docs
d.js docs2y ago
property ThreadChannel#appliedTags The tags applied to this thread
JollyJohn
JollyJohnOP2y ago
oh ill just make it an array then ok thanks, sorry i didnt know it was array do i need to the tag ID or just the name? figured it out
module.exports = {
name: "threadUpdate",
once: false,

async execute(oldThread, newThread, client) {
const threadchl = client.channels.cache.get('1090040369112170546');
let activeThreads = await threadchl.threads.fetchActive()
activeThreads.threads.forEach(async (thread) => {
if (thread.appliedTags = ["t"]) {
setTimeout(async () => {
await thread.send('This thread has been marked as solved.\nIt will be closed shortly.')
}, 5000);
await thread.setArchived(true)
}
})
}
}
module.exports = {
name: "threadUpdate",
once: false,

async execute(oldThread, newThread, client) {
const threadchl = client.channels.cache.get('1090040369112170546');
let activeThreads = await threadchl.threads.fetchActive()
activeThreads.threads.forEach(async (thread) => {
if (thread.appliedTags = ["t"]) {
setTimeout(async () => {
await thread.send('This thread has been marked as solved.\nIt will be closed shortly.')
}, 5000);
await thread.setArchived(true)
}
})
}
}
now I have this, but when the tag isnt on a post it will do it
d.js docs
d.js docs2y ago
In JavaScript, = is used for assignment, == for loose equality, and === for strict equality checks.
x = 1; // assigning x to a value
'1' == 1 // true
'1' === 1 // false
x = 1; // assigning x to a value
'1' == 1 // true
'1' === 1 // false
• Equality and sameness in JavaScript: learn more
JollyJohn
JollyJohnOP2y ago
oh
Want results from more Discord servers?
Add your server