# Limits and premium

> How much one command run can do, what premium changes, and the two premium-only functions.

Every run of a command or event has limits. They keep one script from spamming a server or slowing the bot for everyone.

A **run** is one use of a command or one time an event fires. The pre-hook and post-hook of one run share the same limits.

## Actions per run

| Action | Free | Premium |
|---|---|---|
| `send_message` and `forward_message` (together) | 3 | 5 |
| `send_dm` | 2 | 2 |
| `add_roles` | 5 | 15 |
| `remove_roles` | 5 | 15 |
| `fetch`, different web requests | 5 | 20 |
| `load_file`, different links | 5 | 20 |
| Page lists (`PaginatorV2`) | 3 | 3 |

The command's own reply is **not** counted. Only extra messages are.

Fetching the same web address twice in one run counts once. The second time comes from memory.

Image templates (`render_template`) are limited per minute, not per run: 20 a minute per server on free, 120 on premium. On free, going over stops the script. On premium, the call waits its turn.

## Sizes

| Thing | Free | Premium |
|---|---|---|
| Download size for `fetch` and `load_file` | 5 MB | 100 MB |
| Mongo results per search | 10,000 | 500,000 |
| Images per rendered template | 5 | 15 |

## Code limits

These are the same on every plan:

| Thing | Limit |
|---|---|
| Loop steps in one run (all loops together) | 100,000 |
| Memory | 256 MB |
| `range()` size | 1,000,000 |
| `sleep()` | 1 day |
| Pages in a page list | 200 |
| Suggestions in autocomplete | 25 |

There is **no time limit**. A command can wait for button clicks for minutes. The limits count work, not time.

> **Note:** All loops in one run share the 100,000 steps. A loop inside a loop uses them up fast. Loop over members once, not members times roles.

## Premium-only features

Only these refuse to run on a free server:

| Feature | What happens on free |
|---|---|
| `ask_ai(...)` | Stops with "ask_ai is a premium feature". |
| Repeating jobs (`start_job`) | The job pauses itself when it fires. |
| **Message** events | They do not run. |

Everything else works on free. Premium only raises the numbers above.

`schedule` works on free. It caps how many actions can wait at once: 20 on free, 100 on Starter, 250 on Basic, 1,000 on Advanced. They free up as they run. `cancel_schedule`, `list_schedules` and `render_template` also work on free.

## Dashboard limits

Some limits depend on your plan, but your code never sees them:

- How many commands you can have.
- How many events can be on at once. Free has 2.

See the [Premium](https://ccbot.app/premium) page for each plan.

## Write for free

If a command fits the free limits, it works on every server. A command that sends 5 messages breaks on free servers.
