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