(node:9436) UnhandledPromiseRejectionWarning: TypeError: makeUser is not a function
您好,我尝试在此人执行该命令时自动在名为 users.json 的 cfg 中添加 1 行,但这给了我这个错误。
同样,当我将我的机器人更新到 discord.js V12 时,我遇到了一个错误:
TypeError: makeUser is not a function
这是代码的一部分:
if (!config.servers.servidores.includes(args[4])) {
console.log(yellow + "[" + moment.tz("America/Sao_Paulo").format('HH:mm A') + "] " + red + `[DB]` + reset + ` ${msg.author.username} ` + l7yellow + `->` + lightred + ` Configuração Errada` + reset + ` Status: ` + red + `Servidor` + reset)
const metodoembed = new Discord.RichEmbed()
.setColor("#ff0000")
.setTitle("Database Editor -> Atom")
.setDescription("An `error` was identified when\nmodifying the database.")
.addField('**Type:**', '```http\n' + 'Server' + '```', true)
.addField('Solution:', 'Check the available\nservers in the database', true)
.setThumbnail(`${msg.author.displayAvatarURL}`)
.setTimestamp()
.setFooter(`${msg.author.username}`, `${msg.author.displayAvatarURL}`);
return msg.channel.send(metodoembed); }
//
function updategive(file, json) {
fs.writeFile(file, JSON.stringify(json, null, 2), "utf8", function(err) {
console.log(purple + "[" + reset + moment.tz("America/Sao_Paulo").format('HH:mm A') + purple + "] " + `[?] Banco de Dados atualizado.`);
});
}
if (!users[person]) {
makeUser(person);
}
users[person].attackTime = time;
users[person].concurrents = conc;
users[person].servers = servers;
users[person].expire = moment(expire).unix();
updategive("users.json", users);
return msg.channel.send(responsegive);
}
错误发生在这一行:
if (!users[person]) {
makeUser(person);
}
答案 0 :(得分:0)
您好,您似乎在使用不存在的函数。创建一个名为 makeUser
且参数为 user
的函数。所以它应该看起来像这样 function makeUser(user) {...}
。
此外,如果您使用的是 discord.js v12,请确保将 RichEmbed
替换为 MessageEmbed
。