【发布时间】:2020-01-20 03:37:20
【问题描述】:
if (command == "tgive") {
//Get their current balance
const grab = sql.prepare(`SELECT bal FROM ${args[1]}`).get();
//Grab the value from the first input after the second. Ex: eco tgive 5 Juliana
const pointsToAdd = parseInt(args[0]);
//Add the two values from the database and the args[0] input
const result = +grab.bal + +pointsToAdd;
//Replace the curret value from column bal in table ${args[1]}, with the const result
sql.prepare(`REPLACE INTO ${args[1]} (bal) VALUES ('${result}');`).run();
message.channel.send(`You have ${grab.bal}`);
}
});
在数据库“Juliana”中,bal 列的值为420,但是,每当我使用5 的值运行此命令时,我得到的是You have 420,而不是You have 425,意味着该命令没有添加来自const result的值
【问题讨论】:
-
啊,还有一个注意事项。我现在才注意到这一点:Sqlite3 数据库正在添加另一个具有不同值的集合,因此它在技术上添加了输入的值,但是,它添加了更多行。所以从技术上讲,我在 DB 浏览器中得到了类似的东西:
balFilter1 [420]2 [5567]3 [425]
标签: node.js discord.js better-sqlite3