我是编码的新手,老实说,有时候我不知道自己在做什么,我尝试在网上寻找视频,但是找不到正确的答案,或者我听不到他们想说的话。我希望有人可以告诉我该编码中我该怎么做或我做错了。
const Discord = require("discord.js");
const colors = require("./colors.json");
const bot = new Discord.Client({disableEveryone: true});
const token = 'my token';
const PREFIX = '!';
bot.on("ready", async () => {
console.log(`${bot.user.username} is online!`)
bot.user.setActivity("Live chat", {type: "HELPING"});
})
bot.on("message", async message => {
let args = message.content.substring(PREFIX.length).split(" ");
if (message.author.bot) return;
if (message.content.startsWith ("!Help") || (message.content.startsWith ("!help"))){
let uEmbed = new Discord.MessageEmbed()
.setColor(colors.blue)
.setTitle("**Hello there Human how can i help you today?**")
.addField('**1. If you need help or have an issue with a purchase please type**', '**Purchase**')
.addField('**2. If you need help or have an issue with Impulse mod please type**', '**Impulse**')
.addField('**3. If you need help or have an issue with GTA V Game key please type**', '**GTA V**')
.addField('**4. If you need help or have an issue with Spotify Premium Key type**', '**Spotify**')
.setTimestamp()
.setFooter(`Live chat bot | At your service`, bot.user.defaultAvatarURL)
message.author.send({embed: uEmbed})
}
if (message.content.startsWith ("Purchase") || (message.content.startsWith ("purchase"))){
let uEmbed = new Discord.MessageEmbed()
.setColor(colors.aqua)
.setTitle("**Our bot is not ready for this command**")
.addfiled ("please creat a ticket on the **#『?』support-ticket chennel** in the Knight-Shop Server and staff will be in touch with you shortly.")
.setTimestamp()
.setFooter(`Live chat bot | At your service`, bot.user.defaultAvatarURL)
message.author.send({embed: uEmbed});
}
})
bot.login(token);
(node:3864) UnhandledPromiseRejectionWarning: TypeError: (intermediate value).setColor(...).setTitle(...).addfiled is not a function
答案 0 :(得分:0)
通常,在使用框架/ API之前,您应该首先学习基础语言,在这种情况下,您做了一个简单的错字,addfiled
而不是像上面所做的addField