Attaching already existing attachments to message
Hello there. So, as the title suggests, I want to attach already-existing message attachments on a new message. I am making a
messageDelete
event handler and I want to attach any files that have been deleted to the log message. Here is the code that I have so far:
Now, when I delete a message with an image attached, I get the following error:
I really don't understand why this is a problem. I did think that it might be because I am not using an AttachmentBuilder
, but the wiki clearly states that Array <Attachment>
is also a viable option for the files
argument. If someone could help me, that would be awesome. Thank you for your time and help, it is truly appreciated.6 Replies
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
Alright, so right after posting, I figured out that the problem is that
message.attachments
is a Collection. Using Object.map(message.attachments)
seems to suppress the error, but it won't attach the image.MessageEmbed#attachFiles
has been removed. Files should be attached via the message option object instead:
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
My intelligence strikes once more.
Object.values()
does not work on Collections. I used message.attachments.values()
and it worked perfectly.
Worked, I just had to use message.attachments.values()
. Here's how the final line looks (for anyone who might have the same issue in the future):
Regardless, thank you for your help, it is truly appreciated.MessageEmbed#attachFiles
has been removed. Files should be attached via the message option object instead: