Skip to content

Writing commands

Custom commands in code are managed with !customcommand (or !cc). You need the Manage Server permission. You can also write them in the dashboard editor, which checks your code while you write it.

While custom commands in code are in testing, only Petto’s team can write them.

!customcommand code hello Hello {{ .User.Username }}!

For code with several lines, put it inside a code block. The lines are kept exactly as you wrote them:

!customcommand code roll ```
{{ $sides := 6 }}
{{ if .Args }}{{ $sides = toInt (index .Args 0) }}{{ end }}
🎲 You rolled {{ add 1 (randInt $sides) }}!
```
  • The name has 1 to 32 letters, numbers, - or _, and it cannot be the name of a real command.
  • The code is checked before it is saved. If it has a mistake, nothing is saved and you are told the line and the column.
  • Writing a command with a name that already exists changes it.
  • A server can have up to 100 custom commands, of any kind.

Now anyone in the server can use !roll or !roll 20.

!customcommand codetest {{ sendMessage nil "hi" }}{{ addRole "223456789012345678" }}

codetest runs the code as if you had used the command, and shows what it would print and what it would do. Nothing is sent, no role is given, nothing is saved. Use it as many times as you want while you write.

!customcommand codeshow roll

If the code is long, it comes in a file.

!customcommand template list the ready-made commands
!customcommand template roll install "roll" with its suggested name
!customcommand template roll dice install it with the name "dice"

See Templates. After installing one, change it with !customcommand code <name>.

!customcommand export roll

gives a share code that starts with pc1.. Anyone can use it in another server:

!customcommand import pc1.eyJ2IjoxLC... dice

The name at the end is optional: without it, the name from the share code is used. The imported code is checked like any other. Look at what you import with codetest or codeshow before using it, the same as with anything you copy from other people.

!customcommand trigger hello prefix ?

makes hello start with ?hello as well. See Triggers and prefixes.

!customcommand list shows every custom command, marks the ones written in code with (code), and shows the trigger of the ones that have their own.

!customcommand remove <name> removes any custom command, in code or not.

If the code of a command fails when someone uses it, Petto answers in the channel with the mistake and the line, and says a server admin can fix it. See Errors.