Skip to content

Examples

Every example here has been run with the engine. .Args are the words after the command.

Hello {{ .User.Username }}, welcome to {{ .Guild.Name }}!
{{ sendMessage nil (cembed
"title" "Server info"
"description" (printf "**%s** has %d members." .Guild.Name .Guild.MemberCount)
"color" "#8399ff"
"fields" (cslice (cslice "Channel" .Channel.Mention true) (cslice "Asked by" .User.Mention true))
"footer" (print "Prefix: " .Prefix)
) }}

!roll 20 rolls a number from 1 to 20, and !roll uses 6.

{{ $sides := 6 }}
{{ if .Args }}{{ $sides = toInt (index .Args 0) }}{{ end }}
{{ if lt $sides 2 }}Use a number of 2 or more.{{ return }}{{ end }}
You rolled **{{ add 1 (randInt $sides) }}** (1 to {{ $sides }}).

!sum 4 5 6 answers 15.

{{ if not .Args }}Use: {{ .Prefix }}{{ .Cmd }} 1 2 3{{ return }}{{ end }}
{{ $total := 0 }}
{{ range .Args }}{{ $total = add $total . }}{{ end }}
{{ $total }}
{{ if not (hasRole "223456789012345678") }}Only the staff can use this.{{ return }}{{ end }}
{{ sendMessage nil "Hello, staff!" }}
{{ if hasRole "223456789012345678" }}
{{ removeRole "223456789012345678" }}You no longer have the role.
{{ else }}
{{ addRole "223456789012345678" }}You now have the role.
{{ end }}
{{ $answers := cslice "Yes" "No" "Maybe" "Ask again" }}
{{ index $answers (randInt (len $answers)) }}

!list apples bananas cherries

{{ range $i, $item := .Args }}{{ add $i 1 }}. {{ title $item }}
{{ end }}
{{ $target := 1893456000 }}
{{ $left := sub $target (unix) }}
{{ if gt $left 0 }}It ends in {{ humanizeDuration $left }} ({{ timestamp $target "R" }}).{{ else }}It already ended.{{ end }}
{{ deleteTrigger }}
{{ sendDM (print "You used " .Prefix .Cmd " in " .Guild.Name ".") }}
{{ $total := dbIncr "hugs" 1 }}
{{ .User.Mention }} gave a hug. Hugs in this server: **{{ $total }}**.
{{ if dbGet "daily" .User.ID }}You already claimed it today. Come back later.{{ return }}{{ end }}
{{ dbSetExpire "daily" true 86400 .User.ID }}
{{ $coins := dbIncr "coins" 100 .User.ID }}
You claimed 100 coins. You have {{ $coins }}.
{{ range $i, $entry := dbTop "coins" 5 }}{{ add $i 1 }}. {{ mentionUser $entry.UserID }}: {{ $entry.Value }}
{{ else }}Nobody has coins yet.{{ end }}

Put the ID of a role without moderation permissions. !customcommand code getrole <this code>.

{{ if eq .Trigger "command" }}
{{ sendMessage nil (complexMessage "content" "Press the button to get or lose the role." "components" (cslice (crow (cbutton "label" "Toggle role" "id" "toggle" "style" "primary")))) }}
{{ return }}
{{ end }}
{{ if hasRole "223456789012345678" }}
{{ removeRole "223456789012345678" }}{{ respond "Role removed." true }}
{{ else }}
{{ addRole "223456789012345678" }}{{ respond "Role added." true }}
{{ end }}
{{ if eq .Trigger "command" }}
{{ sendMessage nil (complexMessage "components" (cslice (crow (cselect "id" "buy" "placeholder" "Buy something" "options" (cslice (cslice "Cookie (10)" "cookie") (cslice "Cake (50)" "cake")))))) }}
{{ return }}
{{ end }}
{{ $item := index .Values 0 }}
{{ $price := 10 }}{{ if eq $item "cake" }}{{ $price = 50 }}{{ end }}
{{ $coins := or (dbGet "coins" .User.ID) 0 }}
{{ if lt $coins $price }}{{ respond (printf "You need %d coins, you have %d." $price $coins) true }}{{ return }}{{ end }}
{{ $left := dbIncr "coins" (sub 0 $price) .User.ID }}
{{ respond (printf "You bought a %s! You have %d coins left." $item $left) true }}

Set it with !customcommand trigger gm exact good morning.

Good morning, {{ .User.Mention }}! ☀️