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
Parameter | Description |
---|---|
timeoutId | The ID of the timeout to which the event will react |
time | Time after which the timeout should trigger (not less than 5000 milliseconds) |
timeoutData | Object to be passed to the timeout |
$stopTimeout
Parameter | Description |
---|---|
timeoutId | stop timeout command by id |
timeoutCommand
Parameter | Description |
---|---|
timeoutId | The ID of the timeout to which the event will react |
code | The code that should execute when the timeout triggers |
Example
Also, the $timeoutData[pathProperty?]
function is available to retrieve data passed using $setTimeout
.
- JavaScript
- Loader
<AoiClient>.addCommand({
name: "timeout",
code: `$setTimeout[awaitData;6s;{ "authorID": $usernameID, "username": "$username" }]`
})
<AoiClient>.timeoutCommand({
id: "awaitData",
code: `$print[Timeout data ;$timeoutData[authorID];$timeoutData]`
})
- ESModule
- Commonjs
export default {
id: "awaitData",
code: `$print[Timeout data ;$timeoutData[authorID];$timeoutData]`
};
module.exports = {
id: "awaitData",
code: `$print[Timeout data ;$timeoutData[authorID];$timeoutData]`
}