console.log( authcheck(message.from_id, user.first_name) );return false;
function checkAuth(from_id, first_name) {
return new Promise(function (resolve, reject) {
conn.query(`SELECT * FROM \`users\` WHERE \`id\` = '${from_id}'`, function (error, results) {
if (error) {
console.error(error);
reject(error);
}
let result = JSON.parse(JSON.stringify(results)); // ???
if (result[0] === undefined) {
conn.query(`INSERT INTO \`users\` (\`id\`, \`name\`, \`balance\`) VALUES ('${from_id}', '${first_name}', '0')`, function (error, results) {
if (error) {
console.error(error);
reject(error);
}
resolve('unf');
});
} else {
resolve(['jopa']);
}
});
});
}
async function authcheck(from_id, first_name){
await checkAuth(from_id, first_name);
}
Promise { <pending> }