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
Parameter | Description |
---|---|
awaited | The name of the loop to which the event will react |
every | Interval in milliseconds for code execution (default 60000) |
code | The command code to be executed in the loop |
$loop
Parameter | Description |
---|---|
timeout | The identifier to which each timeoutCommand will react |
time | Time after which the interval will trigger |
timeoutData | Object 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.
- JavaScript
- Loader
<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
`
})
- ESModule
- Commonjs
export default {
awaited: "awaited",
code: `
$print[$awaitedData]
$replyMessage[Text $awaitedData[data]]
$if[$index==10]
$break
$endif
`
};
module.exports = {
awaited: "awaited",
code: `
$print[$awaitedData]
$replyMessage[Text $awaitedData[data]]
$if[$index==10]
$break
$endif
`
};