Skip to main content

Handler Awaited

The following methods, which will be presented below, are responsible for repeating a specified code at intervals of a defined time. However, they have access to the message context (meaning you have access to functions like $sendMessage and so on), and this loop is triggered not directly but through the use of the $loop method.

Parameters

awaitedCommand

ParameterDescription
awaitedThe name of the loop to which the event will react
everyInterval in milliseconds for code execution (default 60000)
codeThe command code to be executed in the loop

$loop

ParameterDescription
timeoutThe identifier to which each timeoutCommand will react
timeTime after which the interval will trigger
timeoutDataObject to be passed

Example

Available Features

Within loop commands, the following functions are available:

  • $break - halt the loop command.
  • $continue - skip the current iteration.
  • $index - returns the number of times the loop has been executed so far.

Additionally, there is the $awaitedData[pathProperty?] function, used to retrieve data passed using $loop. Also, the $break function is available, which stops the loop.

<AoiClient>.addCommand({
name: "loop",
code: `$loop[awaited;1s;{ "data": $usernameID }]
`
})

<AoiClient>.awaitedCommand({
awaited: "awaited",
code: `
$print[$awaitedData]
$replyMessage[Text $awaitedData[data]]
$if[$index==10]
$break
$endif
`
})