Open MinnDevelopment opened 1 year ago
I have this error, when a Thread channel is created in a forum, my bot posts a message in that channel. Once every 5-6 new threads, this error is launched, for now I'm trying to solve it by setting a second of delay so that the instant the thread is created, the bot waits for it to actually be created, so that then when it tries to send the message, don't give the error, because when creating a channel the bot could try to send the message too early and therefore give the error.
I would like to add to this that it only happens to me when there are any attachments on the starter message.
Edit: adding a delay works
I respond with a thread welcomer (what you need to provide, button to mark solved, etc.) on new threads in our support forums. I currently work around this with a 2s timeout, but that's obviously less than ideal. It does not only, but more regularly, happen when people attach screenshots (without the workaround in place).
I've solved this without relying in preset delays posting my solution here to help whoever is having this problem:
async function WaitStarterMessage(thread){
try {
const message = await thread.fetchStarterMessage();
return message;
} catch (error) {
if(error.name != "DiscordAPIError[10008]")
{
console.log(error);
process.exit();
}
return null;
}
}
than, in my code, before everything, I just put it:
let firstMessage;
do{
firstMessage = await WaitStarterMessage(thread);
}while(!firstMessage)
in my function WaitStarterMessage I checked the error to avoid infinite loops in case the error is different from 'Unknown message'. Worked fine here ;D
Also, if you wish, you can use the firstMessage variable after (I use it to retrieve some infos that my bot uses)
Description
When you try making a bot that posts instruction messages on every new forum post, the API returns the following error:
Handling this from the bot perspective seems janky. Would it be possible for discord to handle this more gracefully, potentially by giving it a few seconds before returning an error?
The Documentation also uses this error code in a completely unrelated way:
To me, this refers to the forum channel itself, rather than posts within it. At the very least, I would ask for a different error code to be used.
Additionally: Why does this error exist? What is the motivation behind it?
Steps to Reproduce
Send a message on every new thread, it will break if you're fast enough.
Expected Behavior
This error shouldn't happen.
Current Behavior
This error happens.
Screenshots/Videos
No response
Client and System Information
API v10