0

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

MrMythical
  • 8,908
  • 2
  • 17
  • 45
Ecstasyyy.
  • 49
  • 9

2 Answers2

3

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:

Javascript Basics

JavaScript Comparison and Logical Operators

Lucas Fabre
  • 1,806
  • 2
  • 11
  • 25
0

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!

MrMythical
  • 8,908
  • 2
  • 17
  • 45