我尝试使用以下ping命令,但是当我触发它时,出现以下错误:
代码:
const Discord = require('discord.js');
module.exports.run = async (bot, message, args) => {
let waiting = await message.channel.send("Pinging :hourglass:...").catch(console.error);
let embed = new Discord.MessageEmbed()
.setTitle("Dragonite's & API's Latency", bot.user.avatarURL)
.setColor("#f900ff")
.addField("Dragonite :", `${waiting.createdTimestamp - message.createdTimestamp}` + "ms`", true)
.addField("API :", Math.round(bot.ping) + "ms", true)
.addFooter("Dragonite | Requested by " + message.author.tag)
waiting.edit(embed).catch(console.error);
}
module.exports.help = {
name: "ping",
description: "Calculate Dragonite's & API's Latency.",
usage: "ping",
example: "ping"
}
错误:
(node:23760) UnhandledPromiseRejectionWarning: TypeError: (intermediate value).setTitle(...).setColor(...).addField(...).addField(...).addFooter is not a function
答案 0 :(得分:0)
您的代码中有一个错字,应该纠正它:
const Discord = require('discord.js');
module.exports.run = async (bot, message, args) => {
let waiting = await message.channel
.send('Pinging :hourglass:...')
.catch(console.error);
let embed = new Discord.MessageEmbed()
.setTitle("Dragonite's & API's Latency", bot.user.avatarURL)
.setColor('#f900ff')
.addField(
'Dragonite :',
`${waiting.createdTimestamp - message.createdTimestamp}` + 'ms`',
true
)
.addField('API :', Math.round(bot.ping) + 'ms', true)
.setFooter('Dragonite | Requested by ' + message.author.tag);
waiting.edit(embed).catch(console.error);
};
module.exports.help = {
name: 'ping',
description: "Calculate Dragonite's & API's Latency.",
usage: 'ping',
example: 'ping',
};
答案 1 :(得分:0)
addFooter()
不是函数,因为页脚不能超过一个。而是使用setFooter()
。