是否可以将图片或gif上传到嵌入图片?
我尝试过:.setTitle(message.content)
,但是没有用。
我的代码:
client.on("message", async message => {
if (message.author.bot) return;
if (message.content.startsWith(config.prefix)) return;
if(blacklist.has(message.author.id)) {
return message.reply('You are blacklisted!');
};
let color = message.member.color;
let set = db.fetch(`g_${message.guild.id}`);
if (message.channel.id === set) {
var serverIcon = message.guild.iconURL();
const embed = new Discord.MessageEmbed()
.setAuthor(['331736522782932993', '267818548431290369', '303909506474049537'].includes(message.author.id) ? '? Admin ?' : '')
.setTitle(message.author.tag)
.addField("Message:", message.content)
.setColor('#39FF14')
.setColor(['331736522782932993', '267818548431290369', '303909506474049537'].includes(message.author.id) ? '#ff0f00' : '#39FF14')
.setThumbnail(message.author.avatarURL())
.setFooter(`Server: ${message.guild.name} || UserID: ${message.author.id}`);
message.delete()
client.guilds.cache.forEach(g => {
try {
client.channels.cache.get(db.fetch(`g_${g.id}`)).send(embed);
} catch (e) {
return;
}
});
}
});
答案 0 :(得分:0)
修复您的代码
首先,我注意到您将嵌入的颜色设置了两次。
我建议您删除一个,因为将来可能会导致更多错误。
如果您需要帮助,请考虑将我当前的代码替换为下面随附的代码:
client.on("message", async message => {
if (message.author.bot) return;
if (message.content.startsWith(config.prefix)) return;
if(blacklist.has(message.author.id)) {
return message.reply('You are blacklisted!');
};
let color = message.member.color;
let set = db.fetch(`g_${message.guild.id}`);
if (message.channel.id === set) {
var serverIcon = message.guild.iconURL();
const embed = new Discord.MessageEmbed()
.setAuthor(['331736522782932993', '267818548431290369', '303909506474049537'].includes(message.author.id) ? '? Admin ?' : '')
.setTitle(message.author.tag)
.addField("Message:", message.content)
.setThumbnail(message.author.avatarURL())
.setFooter(`Server: ${message.guild.name} || UserID: ${message.author.id}`)
if (['331736522782932993', '267818548431290369', '303909506474049537'].includes(message.author.id)) {
embed.setColor('#ff0f00')
} else {
embed.setColor('#39FF14')
}
message.delete()
client.guilds.cache.forEach(g => {
try {
client.channels.cache.get(db.fetch(`g_${g.id}`)).send(embed);
} catch (e) {
return;
}
});
}
});
将图像添加到嵌入中
要将图像添加到嵌入中,请执行以下操作:
client.on("message", async message => {
if (message.author.bot) return;
if (message.content.startsWith(config.prefix)) return;
if(blacklist.has(message.author.id)) {
return message.reply('You are blacklisted!');
};
let color = message.member.color;
let set = db.fetch(`g_${message.guild.id}`);
if (message.channel.id === set) {
var serverIcon = message.guild.iconURL();
const embed = new Discord.MessageEmbed() //defining embed
.setAuthor(['331736522782932993', '267818548431290369', '303909506474049537'].includes(message.author.id) ? '? Admin ?' : '') //adding an author to the embed
.setTitle(message.author.tag) //setting a title for the embed
.setDescription(`**Message:**\n${message.content}`) //setting the description for the embed
.setThumbnail(message.author.avatarURL()) //adding a thumbnail
.setImage('ImageURL') //adding a image
.setFooter(`Server: ${message.guild.name} || UserID: ${message.author.id}`) //adding a footer
if (['331736522782932993', '267818548431290369', '303909506474049537'].includes(message.author.id)) { //checks if the authors ID is in the table
embed.setColor('#ff0f00') //if the author is in the table, the embed color will set to red
} else {
embed.setColor('#39FF14') //if the author is not in the table, the embed color will set to green
}
message.delete() //deleting the message that was sent
client.guilds.cache.forEach(g => {
try {
client.channels.cache.get(db.fetch(`g_${g.id}`)).send(embed); //sending the embed
} catch {
return;
}
});
}
});