thread send message

yo, how can i send a message to a thread id i specified via my discord bot?
6 Replies
d.js toolkit
d.js toolkit2mo ago
- 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!
sercan
sercan2mo ago
const thread = await client.channels.fetch(threadId);
if (thread) {
await thread.send(messageContent);
console.log('Message sent to thread!');
} else {
console.log('Thread not found!');
}
const thread = await client.channels.fetch(threadId);
if (thread) {
await thread.send(messageContent);
console.log('Message sent to thread!');
} else {
console.log('Thread not found!');
}
i think it works like this, but I couldn't run it, it shows undefined
Unknown User
Unknown User2mo ago
Message Not Public
Sign In & Join Server To View
sercan
sercan2mo ago
yea but undefined error
_me.xi ツ
_me.xi ツ2mo ago
try logging thread
Jordy
Jordy2mo ago
It looks like you are missing "guild"
const thread = await client.guild.channels.fetch(threadId);
if (thread) {
await thread.send(messageContent);
console.log('Message sent to thread!');
} else {
console.log('Thread not found!');
}
const thread = await client.guild.channels.fetch(threadId);
if (thread) {
await thread.send(messageContent);
console.log('Message sent to thread!');
} else {
console.log('Thread not found!');
}
Also, Iam pretty sure its
const thread = await client.guild.channels.get(threadId);
const thread = await client.guild.channels.get(threadId);
assuming this is in an interaction u might need to replace "client" with "interaction" oops 🫣 yeah its atleast the way I do it, thought id suggest it
interaction.guild.channels.cache.get(channel.id).send({ embeds: [createdTicketEmbed], components: [row] });
interaction.guild.channels.cache.get(channel.id).send({ embeds: [createdTicketEmbed], components: [row] });
or is it cuz im calling to interaction ? :facepalm: