目前,该漫游器仅看到作者的头像和提及内容。我希望该漫游器至少能够看到命令之前的图像(命令之前)或附件。我正在使用discord.js v12。
module.exports.run = (bot, message, args) =>
{
let imageurl;
if(message.mentions.users.first()){
imageurl = message.mentions.users.first().avatarURL({ format: "png", size: 2048 })
}
if(message.attachments[0]){
imageurl = message.attachments[0]
}
if(args[1] && args[1].includes("http")){
imageurl = args[1]
}
if(!message.mentions.users.first() && !message.attachments[0] && !args[1]){
imageurl = message.author.displayAvatarURL({ format: "png", size: 2048 })
}
message.channel.startTyping();
let i1 = Jimp.read(imageurl);
let i2 = Jimp.read(szRandomJailImages[Math.floor(Math.random() * szRandomJailImages.length)]);
Promise.all([i1, i2]).then((images) =>
{
images[0].resize(331, Jimp.AUTO).quality(100);
images[1].resize(400, Jimp.AUTO).quality(100);
images[1].composite(images[0], 32, 20, { mode: Jimp.BLEND_DESTINATION_OVER }).quality(100).getBuffer(Jimp.MIME_PNG, (err, buffer) =>
{
if(err)
{
console.log("Error creating meme");
}
message.channel.send(new Discord.MessageAttachment(buffer, "Piznaysya.png")).then(() => message.channel.stopTyping(true)).catch(() => message.channel.stopTyping(true));
});
});
}