$if

Creates a condition and executes a code depending on the condition.

Usage

$if[condition;if true;if false]

This function has three params.

ParamDescriptionTypeRequired

condition

The condition to test, uses ComparisonSymbols.

String

Yes

if true

The code to execute if the condition is true.

String

Yes

if false

The code to execute if the condition is false.

String

No

Examples

Example #1

bot.commands.add({
    type: "basicCommand",
    name: "example",
    code: `
$if[$isNumber[$message]==true;
Message is a number!
;
Message is not a number!]
`
})

Example #2

This example showcases how you can use $if statement layering. $if statement layering is using $if statements within other $if statements.

bot.commands.add({
    type: "basicCommand",
    name: "example",
    code: `
  $if[$packageVersion==3.0.0;
    v3 😔
;
  $if[$packageVersion==4.0.0;
    Hallelujah v4
;
    v$packageVersion
  ]] 
`
})

Last updated