I have a process that runs when the command is issued in the discord bot, sometimes this process will fail and I need to know when it does. Every time after the command is issued and the process finishes it logs in console console.log ('Process done: All succeded: %s || All failed, %s'), allsucces, allfailed
So every time all succeded = 0 I want the bot to dm me in a discord message
You can simply compare allsucces
value to 0
if (allsucces === 0) {
/* DM Logic */
}
These links might also provide you with some useful information regarding Javascript and how Comparison and logical Operators work:
To compare 2 values, use comparison operators .
Here's how they work:
val == 0 // val has the value 0 but does not *need* to be the same type ("0" == 0 is true)
val === 0 // val is 0, both in value and type
val != 0 // opposite of "==" - val does not have the value 0
val !== 0 // opposite of "===" - val does not have the value 0, or is not the same type
val > 0 // val is more than 0
val < 0 // val is less than 0
val >= 0 // val is more than or equal to 0
val <= 0 // val is less than or equal to 0
See the difference between ===
and ==
in this question
To implement this in your code, use the ===
operator
if (allsucces === 0) {
// allsucces is equal to 0
}
And be sure allsucces
is a number, not a string, otherwise the strict equals operator will make it return false
!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.