Skip to content

Commit 3a07e64

Browse files
committed
docs: migrate execCC section
Signed-off-by: Luca Zeuch <[email protected]>
1 parent f544820 commit 3a07e64

File tree

1 file changed

+48
-20
lines changed

1 file changed

+48
-20
lines changed

content/docs/reference/templates/functions.md

Lines changed: 48 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -328,39 +328,67 @@ Numerical `dict` keys are retrieved as an `int64`, therefore you'd have to write
328328

329329
{{< /callout >}}
330330

331-
## ExecCC
331+
## Executing Custom Commands
332332

333-
{{< callout context="danger" title="Danger" icon="outline/alert-octagon" >}}
333+
These functions enable you to execute a custom command within an already running custom command.
334334

335-
`execCC` calls are limited to 1 / CC for non-premium users and 10 / CC for premium users.
335+
{{< callout context="note" title="" icon="outline/info-circle" >}}
336+
337+
ee
336338

337339
{{< /callout >}}
338340

339-
| **Function** | **Description** |
340-
| ---------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
341-
| `cancelScheduledUniqueCC` ccID key | Cancels a previously scheduled custom command execution using `scheduleUniqueCC`. |
342-
| `execCC` ccID channel delay data | Function that executes another custom command specified by `ccID`. With delay 0 the max recursion depth is 2 (using `.StackDepth` shows the current depth). `execCC` is rate-limited strictly at max 10 delayed custom commands executed per channel per minute, if you go over that it will be simply thrown away. Argument `channel` can be `nil`, channel's ID or name. The`delay` argument is execution delay of another CC is in seconds. The `data` argument is content that you pass to the other executed custom command. To retrieve that `data` you use `.ExecData`. This example is important > [execCC example](/docs/reference/custom-command-examples#countdown-example-exec-cc) also next snippet which shows you same thing run using the same custom command > [Snippets](#execcc-sections-snippets). `execCC` is also thoroughly covered in this [GitHub gist](https://gist.github.com/l-zeuch/9f10d128184509ad531778f26550ed6d). |
343-
| `scheduleUniqueCC` ccID channel delay key data | Same as `execCC`except there can only be 1 scheduled cc execution per server per key (unique name for the scheduler), if key already exists then it is overwritten with the new data and delay (as above, in seconds).An example would be a mute command that schedules the unmute action sometime in the future. However, let's say you use the unmute command again on the same user, you would want to override the last scheduled unmute to the new one. This can be used for that. |
341+
### cancelScheduledUniqueCC
344342

345-
### ExecCC section's snippets
343+
```yag
344+
{{ cancelScheduledUniqueCC <ccID> <key> }}
345+
```
346346

347-
- To demonstrate execCC and .ExecData using the same CC.
347+
Cancels a previously scheduled custom command execution using [scheduleUniqueCC](#scheduleuniquecc).
348+
349+
### execCC
350+
351+
```yag
352+
{{ execCC <ccID> <channel> <delay> <data> }}
353+
```
354+
355+
Executes another custom command specified by `ccID`.
356+
357+
- `ccID`: the ID of the custom command to execute.
358+
- `channel`: the channel to execute the custom command in. May be `nil`, a channel ID, or a channel name.
359+
- `delay`: the delay in seconds before executing the custom command.
360+
- `data`: some arbitrary data to pass to the executed custom command.
361+
362+
#### Example
363+
364+
The following example showcases a custom command executing itself.
348365

349366
```yag
350-
{{ $yag := "YAGPDB rules! " }}
351-
{{ $ctr := 0 }} {{ $yourCCID := .CCID }}
352367
{{ if .ExecData }}
353-
{{ $ctr = add .ExecData.number 1 }}
354-
{{ $yag = print $yag $ctr }} {{ .ExecData.YAGPDB }}
355-
{{ else }}
356-
So, someone rules.
357-
{{ $ctr = add $ctr 1 }} {{ $yag = print $yag 1 }}
368+
{{ sendMessage nil (print "Executing custom command... Got data: " .ExecData) }}
369+
{{ return }}
358370
{{ end }}
359-
{{ if lt $ctr 5 }}
360-
{{ execCC $yourCCID nil 3 (sdict "YAGPDB" $yag "number" $ctr) }}
361-
{{ else }} FUN'S OVER! {{ end }}
371+
372+
{{ sendMessage nil "Starting up..." }}
373+
{{ execCC .CCID nil 5 "Hello, world!" }}
362374
```
363375

376+
### scheduleUniqueCC
377+
378+
```yag
379+
{{ scheduleUniqueCC <ccID> <channel> <delay> <key> <data> }}
380+
```
381+
382+
Schedules a custom command execution to occur in the future, identified by `key`.
383+
384+
- `ccID`: the ID of the custom command to execute.
385+
- `channel`: the channel to execute the custom command in. May be `nil`, a channel ID, or a channel name.
386+
- `delay`: the delay in seconds before executing the custom command.
387+
- `key`: a unique key to identify the scheduled custom command.
388+
- `data`: some arbitrary data to pass to the executed custom command.
389+
390+
To cancel such a scheduled custom command before it runs, use [cancelScheduledUniqueCC](#cancelscheduleduniquecc).
391+
364392
## Interactions
365393

366394
{{< callout context="tip" title="Tip" icon="outline/rocket" >}}

0 commit comments

Comments
 (0)