I am sure many of you still get confused what is new $if and old $if.
So today I will explain them as well as tell how to use old $if.
Note: This guide is for V6 only. V7 will introduce a $if similar to old $if.
First of all,
Usage of old $if:
$if[...]
CODE
$elseif[...]
CODE
$endelseif
$else
CODE
$endif
old $if takes all the code of it as a separate code itself (so you must close it with a $endif),
You can also think it as if your code inside old $if doesn't meet the requirements it will NOT get executed regardless of what is inside old $if but rather the $else will execute.
You can also remove $else if you want.
As well as put the $elseif,
If old $if doesn't meet requirements, it will check if any $elseif meets any but even if $elseif doesn't, $else would get executed.
Usage of new $if
$if[condition;true;false?]
While, new $if is opposite you can consider the code (tho you are not supposed to put code inside of it) as one, meaning it executes both of them but returns the output which is true or false depending upon the condition but it DOES executes them.
Advantage of old $if:
As i said old $if execute each code seperately so it really is helpful when you are using functions like $let, $setGuildVar, $sendMessage, $kick, etc...
For example you have command that checks your message and if your message contains kick it will kick the mentioned user and if your message contains ban it will ban.
So we can use
$if[$message[1]==ban]
$kick[...]
$elseif[$message[1]==kick]
$ban[...]
$endelseif
$else
Sorry but you didn't put any arguments that is necessary.
$endif
Well if you had used new $if then it would had executed both kick and ban (it sounds odd right but it does) and which is bad for this type of commands.
Advantage of new $if
Can be good for checking condition and if condition returns true it will say something.
Like
$sendMessage[the user $replaceText[$replaceText[$checkCondition[$get[hello]==does];true;says];false;doesn't say]]
$let[hello;does]
Can be done like this too using new $if, it is much shorter and easy to use.
$sendMessage[the user $if[$get[hello]==does;says;doesn't say]]
$let[hello;does]
Really easy right!
Now how to use old $if, in order to do that you put $if: "old",
after bot.command and name, like
bot.command({
name: "...",
$if: "old",
code: `...`
})
And for command handler...
module.exports = [{
name: "...",
$if: "old",
code: `...`
}]
This is how you enable old $if but remember when using old $if you can't use new $if but there is a solution.
You can use $ifAwaited, although it was made for different reason but it can used as new $if too. Usage of it is same as new $if.
Like
$ifAwaited[condition;true;false?]