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.
Write a command
Section titled “Write a command”!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.
Test code without saving it
Section titled “Test code without saving it”!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.
See the code of a command
Section titled “See the code of a command”!customcommand codeshow rollIf the code is long, it comes in a file.
Templates
Section titled “Templates”!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>.
Share a command
Section titled “Share a command”!customcommand export rollgives a share code that starts with pc1.. Anyone can use it in another server:
!customcommand import pc1.eyJ2IjoxLC... diceThe 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.
Triggers
Section titled “Triggers”!customcommand trigger hello prefix ?makes hello start with ?hello as well. See Triggers and prefixes.
The list
Section titled “The list”!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.
Remove
Section titled “Remove”!customcommand remove <name> removes any custom command, in code or not.
Who sees a mistake
Section titled “Who sees a mistake”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.
