我正在尝试使用JavaScript为Discord Bot创建一个richEmbed
命令。
我的前缀是“。”
当我尝试运行以下代码时,出现此错误; command is not defined
。
我的命令应该是:.completed
这是我的Discord Bot代码,需要我的帮助才能使其成功运行。
const discord = require("discord.js");
module.exports.run = async (bot, message, args) => {
if (command === `${prefix}completed`) {
var userIcon = message.member.user.displayAvatarURL;
//try
const words = message.content.slice(prefix.length).split(' ');
//check for input
if (!words.length) {
return message.channel.send(`You did not provide any arguments, ${message.author}!`);
}
if (!words.length > 7) {
return message.channel.send(`You provided too many arguments, ${message.author}!`);
}
//split
var goldPot = words[5];
var goldLocation = words[6];
//maths
var goldPotInt = parseInt(goldPot);
var boosterCut = goldPotInt * 0.178;
var totBooCut = boosterCut * 4;
var advertCut = goldPotInt * 0.173;
var guildCut = goldPotInt * 0.115;
//print
var botEmbed = new discord.RichEmbed()
.setDescription("M+ Completed")
.setColor("#8e12db")
.setThumbnail(userIcon)
.addField("Booster 1 " + message.mentions.users.first())
.addField("Booster 2 " + message.mentions.users.second())
.addField("Booster 3 " + message.mentions.users.third())
.addField("Booster 4 " + message.mentions.users.forth())
.addField("Pot of Gold " + goldPot + "k")
.addField("Total Booster Cut" + totBooCut + "k")
.addField("Indi. Booster Cut" + boosterCut + "k")
.addField("Advertiser Cut" + advertCut + "k")
.addField("Guild Cut" + guildCut + "k")
.addField("Location of Gold " + goldLocation)
.addField("Advertiser " + message.mentions.users.fifth());
return message.channel.send(botEmbed);
}
}
module.exports.help = {
name: "completed"
}