【发布时间】:2018-12-05 03:45:30
【问题描述】:
我知道这个问题之前已经在这个网站上处理过,但我已经尝试了我所看到的一切,并且在某些季节没有任何效果......所以它可能更具体。再次,如果我可能遗漏了什么,我深表歉意,但我很新,并且对为什么这不起作用感到沮丧......
我的代码是这样的:
bot.on(`message`, async message => {
if(message.author.bot) return;
if(message.channel.type === "dm") return;
con.query(`SELECT * FROM profile WHERE id = '${message.author.id}'`, (err, rows) => {
if(err) throw err;
var sql;
if(rows.length < 1) {
var sql = (`INSERT INTO profile (id, username) VALUES (${message.author.id}, ${message.author.tag})`);
};
con.query(sql, console.log);
if (err) throw err;
console.log("1 record inserted");
});
我正在尝试将该人的 Discord ID 和用户名放入数据库中。我有几十种不同的代码配置,它不断给我语法错误。我注意到与我看过的其他教程相比,mySQL 8.0 的语法要求非常不同。我参考了 mySQL 网站来尝试找出我的问题。我在这个问题上花了 2 天时间,我已经走到了尽头,所以我寻求帮助!
提前感谢您的宝贵时间! :)
【问题讨论】:
标签: javascript mysql node.js discord discord.js