我正在开发Discord机器人程序,如果用户输入某个命令,我的机器人程序将回复嵌入。
这是我嵌入的代码:
let embedInfo = {
authorName: "My Discord Bot",
authorLink: "the link for my image",
thumbnailLink: "the link for the image",
footer: "Invite us on Discord"
}
let reactivitySeriesInfo = {
title: "The Reactivity Series of Metals",
desc: "In chemistry, a reactivity series (or activity series) is an empirical, calculated, and structurally analytical progression of a series of metals, arranged by their "reactivity" from highest to lowest.",
normalImage: "link",
normalValency: "link",
anagramValency: "link",
anagram: "link"
}
module.exports = {
name: 'chem rs nv',
description: "To view the normal Reactivity series table, with element valencies.",
execute(message, args) {
let embed = new MessageEmbed()
.setAuthor("My Discord Bot", embedInfo.authorLink)
.setTitle("The Reactivity Series of Metals")
.setDescription("In chemistry, a reactivity series (or activity series) is an empirical, calculated, and structurally analytical progression of a series of metals, arranged by their "reactivity" from highest to lowest.")
.setImage(reactivitySeriesInfo.normalValency)
.setTimestamp()
.setFooter("Use db!invite to invite us on Discord")
message.channel.send({embeds: [embed]}).catch(console.error)
}
}
注意;图像";是我在Imgur上传的一张图片的别名。图片链接和名字是我不想透露的。
每当我运行我的机器人脚本时,它都会显示此错误。我知道这个错误不会停止正在运行的脚本,这只是一个DeprecationWarning
。使用命令时,这些命令无论如何都能正常工作。
(node:2416) DeprecationWarning: Passing strings for the URL or the icon's URL for MessageEmbed#setAuthor is deprecated. Pass a sole object instead. (Use `node --trace-deprecation ...` to show where the warning was created)
但无论是在JS还是NodeJS中,我都弄不清唯一对象的含义。有人能解释一下什么是唯一对象吗??
将EmbedAuthorData
传递给setAuthor()
以避免使用不推荐使用的参数。
let author = {
name: "My Discord Bot",
url: "[author url here]",
iconURL: embedInfo.authorLink
}
let embed = new MessageEmbed()
.setAuthor(author)
...