imallett
DIAdiscord.js - Imagine an app
•Created by imallett on 11/2/2023 in #djs-questions
"ERR_INVALID_STATE" "Writer has been released" when trying to repost an attachment
I mean, I only have the one server I can really test this on, but it seems reliable and simple.
12 replies
DIAdiscord.js - Imagine an app
•Created by imallett on 11/2/2023 in #djs-questions
"ERR_INVALID_STATE" "Writer has been released" when trying to repost an attachment
Uh, I mean at the very least one has to manually save and then reupload a file, which is significantly more code than just copying or assigning an array? That's annoying in that it's more code, which is more chance for error and more maintenance, as well as a missed amortization.
Worse, though, is that such a low-level error percolated up with no context. This should not happen; exception popping shouldn't leave the context that gave it meaning; it should go up exactly to the level that has context to handle it. If that's supposed to be me (and maybe it is!), then I'm going to need a better reason than "invalid writer state", because that doesn't mean anything in my level, which concerns "copying an attachment".
I'll also reiterate that this failing feels more like a bug, though, given that "copying an attachment" is a normal use-case (and indeed one that worked previously).
12 replies
DIAdiscord.js - Imagine an app
•Created by imallett on 11/2/2023 in #djs-questions
"ERR_INVALID_STATE" "Writer has been released" when trying to repost an attachment
I think I'm already doing what you suggested as my current workaround: I download the attachment from
received_attachment.url
to a temporary file on my host. Then I reupload it to an Discord.AttachmentBuilder
using .setFile(...)
and the rest, then send that. This works, but it's really annoying. IIUC you're saying the failure implies an issue in undici's fetch. I wouldn't know about that, but in any case this should be investigated and escalated upstream, yes?12 replies
DIAdiscord.js - Imagine an app
•Created by imallett on 11/3/2023 in #djs-questions
Re-sending Embed Unmodified Nevertheless Changes Its Appearance Significantly
Not sure what you mean—do you mean that certain embeds have webhooks for certain functionality (like playing video) that a bot can't reproduce, even by copying?
In any case, stuff like titles and images sizes ought to work as expected . . .
4 replies
DIAdiscord.js - Imagine an app
•Created by imallett on 11/3/2023 in #djs-questions
Reordering Embeds and Attachments in a Message
Great, thank you.
6 replies
DIAdiscord.js - Imagine an app
•Created by imallett on 11/3/2023 in #djs-questions
Reordering Embeds and Attachments in a Message
At the Discord API level, right?
6 replies
DIAdiscord.js - Imagine an app
•Created by imallett on 11/2/2023 in #djs-questions
"ERR_INVALID_STATE" "Writer has been released" when trying to repost an attachment
. . . point is, maybe Discord.js's use of that package is incorrect somehow. It's not a thing I would know how to solve.
12 replies
DIAdiscord.js - Imagine an app
•Created by imallett on 11/2/2023 in #djs-questions
"ERR_INVALID_STATE" "Writer has been released" when trying to repost an attachment
Well, I don't load that dependency explicitly; Discord.js uses it internally, I guess 🤷
12 replies
DIAdiscord.js - Imagine an app
•Created by imallett on 11/2/2023 in #djs-questions
"ERR_INVALID_STATE" "Writer has been released" when trying to repost an attachment
Using
files: some_message.attachments.map( attachment => attachment.url )
instead produced a similar / identical error.12 replies
DIAdiscord.js - Imagine an app
•Created by imallett on 11/2/2023 in #djs-questions
"ERR_INVALID_STATE" "Writer has been released" when trying to repost an attachment
Will try the result with just the URL itself.
As for the
files: Array.from( some_message.attachments.values() )
approach, here is the full stack trace:12 replies
DIAdiscord.js - Imagine an app
•Created by imallett on 11/2/2023 in #djs-questions
"ERR_INVALID_STATE" "Writer has been released" when trying to repost an attachment
As mentioned, I tried that, mapping
attachment => new Discord.AttachmentBuilder( attachment.url )
. Produced same error.12 replies
DIAdiscord.js - Imagine an app
•Created by imallett on 11/2/2023 in #djs-questions
"ERR_INVALID_STATE" "Writer has been released" when trying to repost an attachment
I guess another important thing—theapproach worked just fine in a previous version (I think 13.16.0).
12 replies
DIAdiscord.js - Imagine an app
•Created by imallett on 11/2/2023 in #djs-questions
"ERR_INVALID_STATE" "Writer has been released" when trying to repost an attachment
Basically, it's because
.files
is supposed to be an array whereas some_message.attachments
is a collection.
Re: using a map, it's not a big difference either way; I personally like the array form to stress the type is an array:12 replies