Reputation: 1
I have searched everywhere and followed it but it still does not send the message but has a file attached.
if(message.content.startsWith(`${prefix}test`)){
var content = fs.readFileSync('screenshot.png');
message.channel.createMessage({content: 'a', file: {"file.name": "a.png", "file.file": content}});
console.log(content);
}
Upvotes: -2
Views: 84
Reputation: 295
For your case with a picture file I would suggest using this way:
const { AttachmentBuilder } = require("discord.js");
if(message.content.startsWith(`${prefix}test`)){
const content = new AttachmentBuilder("{path}/screenshot.png");
message.channel.createMessage({content: 'a', files: [content]});
console.log(content);
}
Upvotes: 0