threads issue
guild.threads.cache.forEach((thread) => {
^
TypeError: Cannot read properties of undefined (reading 'cache')
code :
client.once('ready', () => {
console.log(
Logged in as ${client.user.tag}
);
const guild = client.guilds.cache.get(guildId);
if (!guild) {
console.error(Guild with ID ${guildId} not found.
);
return;
}
console.log(Found guild: ${guild.name} (${guild.id})
);
guild.threads.cache.forEach((thread) => {
console.log(Sending message to thread: ${thread.name} (${thread.id})
);
thread.send(hardcodedMessage)
.then(() => console.log(Sent message to thread: ${thread.name}
))
.catch((error) => console.error(Error sending message to thread: ${thread.name}
, error));
});
});1 Reply
- 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 staff