> ## Documentation Index
> Fetch the complete documentation index at: https://wiki.petto.sbs/llms.txt
> Use this file to discover all available pages before exploring further.

# Petto Code Generator

> A free website that builds custom commands in Petto Code with forms, lets you try them in a test channel and gives you the command to paste.

## Overview

The **Petto Code Generator** is a website that writes [Petto Code](https://wiki.petto.sbs/automation/petto-code.md) for you. You pick what the command does with forms, try it in a channel that looks and works like Discord, and copy the command into your server.

Open it at **[codegen.petto.sbs](https://codegen.petto.sbs)**. It is free and needs no login.

> [!NOTE]
>
> **Nothing leaves the page.** The generator never touches your server. Your commands only reach Discord when you paste the install command yourself.

## How it works

**1. Build it**

Open the **Builder**. Start from one of the **21 recipes**, from an official template, or from an empty command. Fill only the parts you need: the name, how it starts, the answer, buttons, a form, reactions, requirements and extras. Variables like `{user}` or `{server}` work anywhere. The code is written and checked while you go.

**2. Try it**

The **Try it** tab is a test channel that runs the command with **the real engine of Petto**. Type the command, press its buttons, choose in its menus, fill its forms and react. You see what it would print and what it would do: roles given or taken, DMs, deleted messages, the stored data and a log of every use. You can switch between **two test people** to try what someone else sees.

**3. Install it**

The **Install** tab gives the `!customcommand code` command ready to paste in your server, and the `!customcommand trigger` command when it starts with its own prefix or words. It also gives a **share code** (`pc1.`) for `!customcommand import`.

```javascript theme={null}
!customcommand code verify {{ ... }}
!customcommand import pc1.<code> verify
```

![liam pastes !customcommand code verify with the code in a block and Petto answers that verify was created](https://mintcdn.com/wikipetto/FghHti1ndnhhOsRU/images/discord/automation/petto-code-generator-install-code.webp?fit=max\&auto=format\&n=FghHti1ndnhhOsRU\&q=85\&s=7aea4fd581b469ed371f33f225293499)

In Discord: the install command pasted in a server; Petto checks the code and saves it.

![liam pastes !customcommand import with the pc1. share code and the name verify, and Petto answers that verify was imported](https://mintcdn.com/wikipetto/FghHti1ndnhhOsRU/images/discord/automation/petto-code-generator-install-import.webp?fit=max\&auto=format\&n=FghHti1ndnhhOsRU\&q=85\&s=971ff1c897cf0496f04290ca2115ee19)

In Discord: the same command installed from its share code.

> [!TIP]
>
> Want to change something by hand? **Edit as code** opens the command in the code editor, with colors, line numbers, a check on every key (with the line and the column of a mistake) and every function and piece of data ready to insert.

## What it can build

> [card] Text and embeds
>
> An answer in the channel, in a DM or in another channel, as text or an embed with fields, colors, images and the author.

> [card] Buttons and menus
>
> Buttons and a dropdown menu that answer, give or take a role, or open a form. They can be locked to the person who used the command.

> [card] Forms
>
> A pop-up form (modal) with text fields, menus of choices, radio buttons, checkboxes, pickers of members, roles and channels, files to upload and texts that inform. The answers go into a message, for example to a staff channel.

> [card] Reactions
>
> Something that happens when people react: a role, a DM, an answer in the channel or a change to the message. A reaction can be only for the person who used the command.

> [card] Roles
>
> Give, take or toggle a role from a command, a button, a menu option or a reaction.

> [card] Counters and random answers
>
> A counter that goes up on every use or click, and an answer picked at random from a list.

> [card] Cooldowns and requirements
>
> How often a command can be used, and which roles or channels it needs.

> [card] Coins and rankings
>
> Stored data for each member: a daily reward, a balance and a leaderboard of the server.

> [card] Triggers
>
> Start with the prefix of Petto, with a prefix of its own (`?hello`), or with a message that starts with, is exactly or contains some words.

> [card] Recipes and templates
>
> 21 recipes (verification, role menu, reaction role, suggestions, reports, daily coins, leaderboard, requests by reaction and more) and every official template of the bot.

## Change a message, only who asked, and closing it

These make request cards and other messages that change over time possible **without writing code**.

* **Some parts of the embed:** when a button, a menu option or a reaction changes the message, it can keep the embed as it is (with everything the command wrote in it) and change only the parts you fill: a new **title**, **description**, **footer** or **color**. A part you leave empty stays.
* **Only who used the command:** for each button and each reaction. Anyone else pressing the button is told *This is not for you*; anyone else's reaction is taken away, with an optional DM like *Only who asked can confirm it.* A reaction knows who used the command because Petto remembers it with the message (`.Message.CommandUserID` in [Petto Code](https://wiki.petto.sbs/automation/petto-code.md#who-used-the-command)).
* **Close the message by its footer:** when the footer of the embed says a word, like *Delivered*, its buttons, menus and reactions stop answering. A reaction is taken away, and a click gets an optional answer like *This one is already closed.*

### Recipe: Requests by reaction

The **Requests by reaction** recipe puts the three together. `!req a cake` sends a card with the request and deletes the message of the command:

* 🦋 is for anyone and sets the footer to *Claimed by `{name}`*.
* 🎀 is **only for who asked** and sets the footer to *Delivered*. Anyone else's 🎀 is taken away.
* Once the footer says *Delivered*, the card is closed and stops answering.

Open it in **Templates**, change the texts and the emojis, try it in the test channel as two people, and install it.

![The request card of chu for a cake for the server birthday, with the butterfly and bow reactions to claim it and confirm the delivery](https://mintcdn.com/wikipetto/Z-XTVemdYTr1KRaH/images/discord/automation/petto-code-generator.webp?fit=max\&auto=format\&n=Z-XTVemdYTr1KRaH\&q=85\&s=3f79ad792ad6180759fce3f7d93daf8f)

In Discord: the Requests by reaction recipe installed and used with !req, run by Petto's engine.

## Share codes, both ways

A share code starts with `pc1.` and holds a whole command.

* **Out:** the **Install** tab gives the share code of your command. Anyone can use it in their server with `!customcommand import <share code> [name]`.
* **In:** paste a share code in the **Import** tab to read its code and check it **before you use it**. Then open it in the editor to change it. The whole line works too, with `!customcommand import` in front.

A code from `!customcommand export` in Discord works in the generator, and a code from the generator works in Discord.

## My commands

**My commands** keeps the commands you save **in your browser**. You can export them as a JSON file and import them again on another device. Nothing is saved on a server.

The website is in **English, Spanish and Portuguese**, with a light and a dark theme. The default texts of the commands follow the language you pick.

## Same engine as the bot

> [!NOTE]
>
> The generator runs **the same Petto Code engine as Petto**, with the same checks, functions and limits (10,000 characters, 10,000 steps, 250 ms of running time, 25 reads and writes of stored data per use). **What works in the generator works in your server.**
>
> What it cannot test is what depends on Discord: the permissions of Petto in the channel, a role above Petto's role or with moderation permissions, or someone with closed DMs. Petto checks those when the command runs. See [Limits and safety](https://wiki.petto.sbs/automation/petto-code.md#limits-and-safety).

The full documentation of the language is at **[code.petto.sbs](https://code.petto.sbs)**, with a page about the generator at [code.petto.sbs/generator](https://code.petto.sbs/generator).

See [Petto Code](https://wiki.petto.sbs/automation/petto-code.md) for the commands and [Custom commands](https://wiki.petto.sbs/automation/custom-commands.md) for plain text and embed commands.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.