I've been trying to make a command that when you send an image or a url of an image it puts that image on another image that I already have in the code and I keep getting errors every time I try changing it to either imageTemp
(which is the image you put your image on) or image`` or
messageAttachment```. I'll put my code below so you could see what the problem is.
const { MessageAttachment } = require('discord.js');
const Jimp = require('jimp');
const discord = require('discord.js')
module.exports = {
name: "img",
aliases: [],
run: async (client, message, args) => {
let messageAttachment = message.attachments.size > 0 ? message.attachments.array()[0].url : null
try {
let imageTemp = "https://upload.wikimedia.org/wikipedia/commons/8/8a/Banana-Single.jpg"
let image = await Jimp.read(messageAttachment);
let buffer = await image.getBufferAsync(Jimp.MIME_JPEG);
Jimp.read(imageTemp).then(image => {
image.composite(messageAttachment, 10, 10)
})
message.channel.send(new MessageAttachment(buffer));
} catch (err) {
console.log(err);
message.channel.send('Oops, there was an error. Try inputting the command again.');
}
},
};
And here's the result and the errors I get https://i.stack.imgur.com/vnTkn.jpg