我一直在尝试创建一个命令,当您发送图像或图像的 url 时,它会将该图像放在我已经在代码中拥有的另一个图像上,并且每次尝试将其更改为任何一个时都会出现错误imageTemp
(是您放置图像的图像)或image`` or
messageAttachment```。我会把我的代码放在下面,这样你就可以看到问题所在。
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.');
}
},
};
这是我得到的结果和错误https://imgur.com/a/C6RcTOf