在嵌入 Discord.js 中发送 Canvas [英] Send Canvas in embed Discord.js

查看:15
本文介绍了在嵌入 Discord.js 中发送 Canvas的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在嵌入消息中发送画布图像,但这样做我只能发送照片然后单独嵌入(由于声誉不佳,我无法附加照片 D :)

I'm trying to send the canvas image in an embed message, but doing it this way I only get it to send the photo and then the individual embed (I can't attach photos because of the poor reputation D :)

对不起,英语不是我的母语

Sorry for the English, it is not my native language

    let channel = member.guild.channels.get('720372789286141963')
const Mensaje = {
    color: 1752220,
    title: `<a:pepeShoot:659762885706383380> | **Hola ${member.user.username}!**`,
    description: `**Bienvenid@ a:** 
 Psyco RP`,
};

const file = {
    attachment: await createCanvas(),
    name:'bienvenida.jpg'
}
    
        channel.send({embed: Mensaje, files : [file]});
});

推荐答案

尝试缓冲图片,然后使用.attachFiles(),像这样:

Try buffering the image and then use .attachFiles(), like this:

const attachment = new Discord.MessageAttachment(canvas.toBuffer(),'bufferedfilename.png'); 
 
const embed = new Discord.MessageEmbed()
    .attachFiles(attachment)
    .setImage('attachment://bufferedfilename.png');

这篇关于在嵌入 Discord.js 中发送 Canvas的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆