[英]how do I use a downloaded image on a embed with discord.js V13
我想删除显示“.setImage”的图像链接,并将其替换为下载的图像 我将如何处理 go?
/** @format */
const Command = require("../Structures/Command.js");
const Discord = require("discord.js");
module.exports = new Command({
name: "Cookie",
description: "sends a image",
permission: "SEND_MESSAGES",
async run(message, args, client) {
const embed = new Discord.MessageEmbed();
embed
.setTitle("here is your cookie")
.setDescription(
"photo discription"
)
.setColor("BLURPLE")
.setTimestamp()
.setImage(
"https://assets.bonappetit.com/photos/5ca534485e96521ff23b382b/1:1/w_2700,h_2700,c_limit/chocolate-chip-cookie.jpg"
)
message.reply({ embeds: [embed] });
}
});
您可以使用像Imgur这样的图片主机来上传您下载的图片并获取它的图片 url,然后在您的.setImage()
方法中使用该 url,您也可以使用另一个图片主机,只需使用您喜欢的即可:)
编辑:
也可以在没有链接或图像主机的情况下执行此操作,这是一个示例:
const image = new Discord.MessageAttachment('./path/to/image.png', 'attachement-name.png')
const embed = new Discord.MessageEmbed();
embed
.setTitle("here is your cookie")
.setDescription(
"photo discription"
)
.setColor("BLURPLE")
.setTimestamp()
.setImage(
"attachment://attachement-name.png"
)
message.reply({ embeds: [embed], files: [image] });
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.