gpt4 book ai didi

javascript - Discord.js SQLITE_ERROR : table scores has no column named points

转载 作者:行者123 更新时间:2023-11-30 20:30:56 24 4
gpt4 key购买 nike

我有以下错误

UnhandledPromiseRejectionWarning: Error: SQLITE_ERROR: table scores has no column named points 

有人知道解决办法吗?

我也在用discord.js commando,所以我的用户是在运行中定义的...

代码:

run(msg, {user, reason}) {
msg.delete()
if(!user) {msg.say(`**Cannot find user! Make sure it's a valid member of this server!**`)
} else {
msg.say(`**${user.tag} has been warned for ${reason}!**`)
sqlite.get(`SELECT * FROM scores WHERE userId = "${user.id}"`).then(row =>{
if (!row) {
sqlite.run("INSERT INTO scores (userId, points) VALUES (?,?)", [user.id, 1])
} else {
sqlite.run(`UPDATE scores SET points = ${row.points + 1} WHERE userId = ${user.id}`)
}
}).catch(()=>{
sqlite.run(`CREATE TABLE OF NOT EXISTS scores (userId TEXT, points INTEGER)`).then(()=> {
sqlite.run(`INSERT INTO scores (userId, points) VALUES (?, ?)`, [user.id, 1])
})
})


}

最佳答案

您需要将 promise 链接起来才能以这种方式捕获它们。

sqlite.get(`SELECT * FROM scores WHERE userId = "${user.id}"`).then(row =>{
if (!row) {
return sqlite.run("INSERT INTO scores (userId, points) VALUES (?,?)", [user.id, 1])
} else {
return sqlite.run(`UPDATE scores SET points = ${row.points + 1} WHERE userId = ${user.id}`)
}
}).catch(()=>{
return sqlite.run(`CREATE TABLE OF NOT EXISTS scores (userId TEXT, points INTEGER)`).then(()=> {
return sqlite.run(`INSERT INTO scores (userId, points) VALUES (?, ?)`, [user.id, 1])
}).catch((err) => {
console.error(err);
});

关于javascript - Discord.js SQLITE_ERROR : table scores has no column named points,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50340434/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com