Skip to main content

Handler Timeout

The Timeout function simplifies the creation of actions that require time. The timeout cannot use message context, meaning you can't use methods like $replyMessage and similar functions. Additionally, the time limit depends on setTimeout in Node.js. Even if you restart the bot, the timeout will continue to work.

Parameters

$setTimeout

ParameterDescription
timeoutIdThe ID of the timeout to which the event will react
timeTime after which the timeout should trigger (not less than 5000 milliseconds)
timeoutDataObject to be passed to the timeout

$stopTimeout

ParameterDescription
timeoutIdstop timeout command by id

timeoutCommand

ParameterDescription
timeoutIdThe ID of the timeout to which the event will react
codeThe code that should execute when the timeout triggers

Example

Also, the $timeoutData[pathProperty?] function is available to retrieve data passed using $setTimeout.

<AoiClient>.addCommand({
name: "timeout",
code: `$setTimeout[awaitData;6s;{ "authorID": $usernameID, "username": "$username" }]`
})

<AoiClient>.timeoutCommand({
id: "awaitData",
code: `$print[Timeout data ;$timeoutData[authorID];$timeoutData]`
})