Thread fetchStarterMessage with Attachments

Working on a bot that detects when a thread is created in a particular forum, and then returns the first starter message (original post message created by OP). All works well with the code below, until an image is uploaded in which I get the error: DiscordAPIError[10008]: Unknown Message. Is there a way for me to get the image data (e.g. a link to it) when the message is created? My guess is that the message is taking longer to generate since there is a attachment included. How can I resolve this? Thanks.
const { ChannelType } = require("discord.js");

module.exports = {
name: "threadCreate",
async execute(thread, client) {
if (thread.type === ChannelType.PublicThread && thread.parentId === process.env.BUG_FORUM_ID) {
const message = await thread.fetchStarterMessage();
console.log(message);
}
},
};
const { ChannelType } = require("discord.js");

module.exports = {
name: "threadCreate",
async execute(thread, client) {
if (thread.type === ChannelType.PublicThread && thread.parentId === process.env.BUG_FORUM_ID) {
const message = await thread.fetchStarterMessage();
console.log(message);
}
},
};
5 Replies
d.js toolkit
d.js toolkit3w 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!
Benluka.dev
Benluka.dev3w ago
message.attachments dont work? ah just saw the error. Def add a timeout You could add a set time out then fetch it
WreckNoFear
WreckNoFearOP3w ago
yep youre 100% right wrapped it in a setTimeout and it worked is there a better way to do that though then specifying for it to timeout say 3 seconds i guess there isnt necessarily anything wrong with it
Benluka.dev
Benluka.dev3w ago
I don't think, i faced similar thing before when my bot used to send message on each new thread. Sometimes, the starter message gets delayed
WreckNoFear
WreckNoFearOP3w ago
ah fair, all good then thank you for that!
Want results from more Discord servers?
Add your server