Well, I'm new to programming and I have a question. I'm using firebase database, and I want to get values from two users.
Here is my database, and I have these two user ids as an example. I want to check if the value "mstatus"
of the first user is set to "CASADO"
, if it is, the bot will send an error message.
At first I tried to do a verification of only the first user, but it didn't work out very well, the bot sent the error message, but he also executed a command that was not supposed to be executed when the value had defined "CASADO"
database.ref(`Servidores/${message.guild.id}/Users/${user.id}/Casamento`).once('value').then(async function(fg) {
if (fg.val().mstatus === 'CASADO') {
return message.reply('oi')
}
});
Then I made the code that was to be sent if the values were all right
database.ref(`Servidores/${message.guild.id}/Users/${message.author.id}/Casamento`).once('value').then(async function(db) {
if (db.val() === null) {
mCasar()
}
else if (db.val().mstatus === 'CASADO') {
// I summarized the code to make it easier for you to understand
return message.channel.send(embederro)
} else {
mCasar()
}
This is what is happening to my command, can someone help me?
Via Active questions tagged javascript - Stack Overflow https://ift.tt/2FdjaAW
Comments
Post a Comment