Custom Command
FunctionsUseful Functions

$function

Create a user-defined function that can be called by $callFunction or $functionName.

Usage

$function[Function name;Param 1 (optional);Param 2...(optional)]

Example

$function[printHello;name]
    Hello $name
$endFunction

Call the function using $callFunction:

Member
9/5/2026

!!exec $function[printHello;name]
Hello $name 👋
$endFunction

$callFunction[printhello;Mika]

Custom Command
APP
9/5/2026

Hello Mika 👋

Call the function using $printHello:

Member
9/5/2026

!!exec $function[printHello;name]
Hello $name 👋
$endFunction

$printhello[Mika]

Custom Command
APP
9/5/2026

Hello Mika 👋

A function name can't start with number, and must be within [A-Z or a-z or _ or 0-9] for short format ($functionName) but if you are using $callFunction to call the function, any name is valid.

Code inside the function is isolated from outside, which means changing of variables, arrays, random,...won't effect the outside. you can access outside temporary variables (assigned by $let) but you can't change them.

Default parameter values

Parameters can have a default value by using =. The default value is used when the parameter is not provided when calling the function.

$function[greet;name=Mika]
    Hello $name 👋
$endFunction

Calling the function without providing name:

$greet[]

outputs:

Hello Mika 👋

Providing a value overrides the default:

$greet[Alex]

outputs:

Hello Alex 👋

Default values can also be used with multiple parameters:

$function[greet;name=Mika;greeting=Hello]
    $greeting $name 👋
$endFunction

Calling:

$greet[]

outputs:

Hello Mika 👋

While providing custom values:

$greet[Alex;Welcome]

outputs:

Welcome Alex 👋

When defining default parameter values, spaces in the parameter name are ignored, but spaces in the default value are preserved.

  • param=def and param =def are equivalent.
  • param= def is different from param=def because the spaces are part of the default value.
  • =abc is invalid because a parameter name is required.

Function difficulty: Difficult

Tags: Function Custom Functions Nested Code

On this page