The dashboard editor
You can write commands in code in the dashboard, with a real editor, instead of typing them in Discord. It does the same as
!customcommand and follows the same rules, but it checks the code while you write it and lets you test it as
many times as you want.
While custom commands in code are in testing, only Petto’s team sees the editor. It appears in the menu of the dashboard under Code, as Commands in code.
Open it
Section titled “Open it”Dashboard → your server → Code → Commands in code. You need the Manage Server permission on that server.
What is on the page
Section titled “What is on the page”| Part | What it does |
|---|---|
| Your commands | The commands of your server that are written in code, each one with how it starts (!roll, ?hello, startswith: hey…). Click one to open it. New starts an empty one |
| Name | The name of the command, with the prefix of your server in front. A saved command keeps its name; to rename one, save a new one and delete the old one |
| The editor | Where the code goes. The numbers on the left are the lines. The counter at the bottom is how many of the 10,000 characters you used |
| Templates | The ready-made templates. Choosing one puts its code and its name in the editor, ready to change |
| Functions | Every function with the number of arguments it takes. Search by name and click one to put it in the code |
| What starts it | The trigger of the saved command |
| Test | Runs the code and shows what it would do, without doing it |
Writing
Section titled “Writing”- The code is checked while you write. A moment after you stop typing, the line under the editor says The code is fine or tells you the mistake with its line, and that line is marked red in the numbers. See Errors.
- Tab puts two spaces. Ctrl+S (or Cmd+S) saves. Ctrl+Enter runs the test.
- If you leave the page, or open another command or a template, with changes that are not saved, you are asked first.
Saving
Section titled “Saving”Save checks everything again on the bot before saving, with the same rules as in Discord: the name has 1 to 32 letters,
numbers, - or _, it cannot be the name of a real command, the code must have no mistakes, and a server can have up to 100
custom commands. If something is wrong, the reason appears under the editor and nothing is saved.
Writing a name that already exists changes that command. The code of a saved command starts working at once.
Testing
Section titled “Testing”The test runs your code as you, with the data of that moment (your name, your roles, the server), and shows two things:
- It would print: the text the command would answer with.
- It would do: every action the code asked for, in words (send “hi” here, give the role …).
Nothing is sent, no role is given, nothing is saved, and what the code stores with dbSet or dbIncr lasts only until the
end of that test, so you can try as much as you want without changing your server’s stored data.
- Arguments: write them as they would be typed after the command, like
4 5 6, and the code reads them in.Args. - Someone uses a button / a menu: to test the part of the code that runs when a button or a menu is used,
choose that option and write the id of the button or the menu, and for a menu the value that was chosen. The code
runs with
.Triggerset to"button"or"select", sorespondandupdateMessagework. - The test shows the steps and the time it used, to compare with the limits, and the mistakes it finds with their line.
The test is limited like the commands are, so a loop that never ends stops with a message.
What starts it
Section titled “What starts it”Below the editor you choose how the saved command starts: the prefix of Petto, its own prefix, a message that starts with some words, a whole message, or a message that has some words. Write the prefix or the words, and press Save trigger. A command has to be saved before it can have a trigger. See Triggers and prefixes.
Delete
Section titled “Delete”Delete removes the command, after asking. Its buttons stop working and answer That command does not exist anymore.
