-
Notifications
You must be signed in to change notification settings - Fork 45
Open
Description
The Problem
When adding files as an array to the createMessage function, files do not display correctly as they contain errors. This happens even though each item in the array is a correct file object that works if sent individually.
Example
Running this function:
msg.channel.createMessage("Some images:", [
{ file: readFileSync("./assets/images/PauseChamp.png"), name: "PauseChamp.png" },
{ file: readFileSync("./assets/images/PagChomp.png"), name: "PagChomp.png" }
]);
Returns this:
If these files are attempted to be downloaded, a webpage displays, "The image cannot be displayed because it contains errors."
Fix
if (file && Array.isArray(file)) {
file.forEach(function(f) {
f.file = Buffer.from(f.file, 'base64');
});
};
I was able to find a quick fix that allows both images to be sent. This is by adding the previous lines into the files /src/sharding/clustermanager.js
and /src/structures/SyncedRequestHandler.js
after,
if (file && file.file) file.file = Buffer.from(file.file, 'base64');
and
if (file && file.file) file.file = Buffer.from(file.file).toString('base64');
respectively.
Metadata
Metadata
Assignees
Labels
No labels