📚
YAGPDB
  • YAGPDB Coding System - Documentation
  • Getting Started
  • Useful Functions
  • Primary Level
    • The Dot and Variables
      • User
      • Guild / Server
      • Member
      • Channel
      • Message
      • Reaction
      • Time
    • Custom Types
    • Functions
      • Type Conversion
      • String Manipulation
      • Math Functions
      • Message Functions
      • Mentions
      • Role Functions
      • Current User
      • Miscellaneous
      • ExecCC
    • Conditional Branching
  • Intermediate Level
  • Database
  • Range Action
  • With Action
  • Custom Embeds
  • Advanced Level
    • Using RegEx
  • Custom Commands Examples
    • Texas Hold'em
Powered by GitBook
On this page
  • Preface
  • Function

Was this helpful?

  1. Primary Level
  2. Functions

ExecCC

execCC calls are limited to 1 / CC for non-premium users and 10 / CC for premium users

PreviousMiscellaneousNextConditional Branching

Last updated 4 years ago

Was this helpful?

Preface

ExecCC functions are useful when your commands need many dbTopEntries/dbBottomEntries/dbCount (the restriction for non-premium users of YAGPDB, more info about database ) functions or you want to make 2 commands together.

{{if not .ExexData}}
{{range (dbTopEntries "test" (dbCount "test") 0)}}
{{end}}
{{execCC .CCID nil 10 ""}}
{{else}}
{{range (dbTopEntries "lottery" (dbCount "lottery") 0)}}
{{end}}
{{end}}

The execCC functions can also be used when you want to make a combination of main commands and sub commands, example .

Function

Function

Description

execCC ccID channel delay data

scheduleUniqueCC ccID channel delay key data

Same as execCCexcept there can only be 1 scheduled cc execution per server per key, if key already exists then it is overwritten with the new data and delay.

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.

cancelScheduledUniqueCC ccID key

Cancels a previously scheduled custom command execution using scheduleUniqueCC

Example:

  • To demonstrates execCC and .ExecData using the same CC. Useful when both of the two commands can be triggered by the user, but one of which will execute the other one when the user triggers it.

{{ $yag := "YAGPDB rules! " }}
{{ $ctr := 0 }} {{ $yourCCID := .CCID }}
{{ if .ExecData }}
    {{ $ctr = add .ExecData.number 1 }}
    {{ $yag = joinStr "" $yag $ctr }} {{ .ExecData.YAGPDB }}
{{ else }} 
    So, someone rules.
    {{ $ctr = add $ctr 1 }} {{ $yag = joinStr "" $yag 1 }}
{{ end }}
{{ if lt $ctr 5 }}
    {{ execCC $yourCCID nil 10 (sdict "YAGPDB" $yag "number" $ctr) }}
{{ else }} FUN'S OVER! {{ end }}
  • To demonstrate the way to escape restrictions >>> range over databases once and execute another custom command to range over databases again

{{range (dbTopEntries "lottery" (dbCount "lottery") 0)}}
Do something here
{{end}}
{{execCC 140 nil 1 ""}}

Main command above, and sub command below (main command >>> execute sub command).

{{range (dbTopEntries "lotterywintime" (dbCount "lotterywintime") 0)}}
Do another thing here
{{end}}
  • To demonstrate the way to use execCC >>> the main & sub commands.

{{$args := parseArgs 2 ""
 (carg "duration" "countdown-duration")
 (carg "string" "countdown-message")}}

{{$t := currentTime.Add ($args.Get 0)}}
{{$mID := sendMessageRetID nil (joinStr  "" "countdown starting..." $t.String)}}
{{execCC REPLACE-WITH-NEXT-CC-ID nil 0 (sdict "MessageID" $mID "T" $t "Message" ($args.Get 1)) }}

Main command below, and sub command above (sub command >>> execute main command).

{{$timeLeft := .ExecData.T.Sub currentTime}}
{{$cntDownMessageHeader := joinStr "" "Countdown Timer: " .ExecData.Message}}
{{$formattedTimeLeft := humanizeDurationSeconds $timeLeft}}

{{$t := .ExecData.T}}
{{$mID := .ExecData.MessageID}}
{{$ts := .TimeSecond}}

{{if lt $timeLeft (mult .TimeSecond 30)}}
  {{range seq 1 (toInt $timeLeft.Seconds) }}
    {{$timeLeft := $t.Sub currentTime}}
    {{$formattedTimeLeft := humanizeDurationSeconds $timeLeft}}

    {{editMessage nil $mID (joinStr "" $cntDownMessageHeader "\nTime left: " $formattedTimeLeft " seconds")}}
    {{if gt $timeLeft $ts}} {{sleep 1}} {{end}}
  {{end}}
  {{editMessage nil  .ExecData.MessageID (joinStr "" $cntDownMessageHeader "\nTime left: **ENDED**")}}
{{else}}
    {{editMessage nil .ExecData.MessageID (joinStr "" $cntDownMessageHeader "\nTime left: " $formattedTimeLeft)}}
    {{execCC REPLACE-WITH-CURRENT-CC-ID nil 10 .ExecData}}
{{end}}
  • Special case.

Command Type: Minute Interval; Interval: 10 minutes.

{{if not .ExecData}}
{{execCC .CCID nil (randInt 1 600) ""}}
{{else}}
Your codes here.
{{end}}

Although the command is triggered every 10 minutes, it will still delay from 1 to 599 seconds (you can specify a time for it). After the delay, the main command will start to be executed.

Function that executes another custom command specified by ccID,max recursion depth is 2 (using .StackDepth shows the current depth) and it's 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. Thedelay 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 > also next snippet which shows you same thing run using the same custom command > .

here
here
execCC example
Snippets