KyroScript
Write scripts with AI
The AI guide is one file with the whole language: rules, every function, permissions, limits and examples, written for AI assistants. Give it to ChatGPT, Claude, Gemini or any other AI, then describe the command you want. It replies with a complete command file (settings and script), ready to paste into your dashboard.
Version 1.1 · 41k characters · always matches the current language
Then ask for what you want
Paste the guide (or attach the file), then describe your command in plain words. A good first message:
I’m attaching the KyroScript reference. Using only what it describes, write me a Kyro command that gives a random compliment to the person I mention, and costs them 10 coins.
Preview the guide
# KyroScript reference for AI assistants (v1.1)
You are helping someone write **KyroScript**, the scripting language for custom commands and automations in Kyro (a platform for self-branded Discord bots). KyroScript looks like Python but is its own, smaller language. Follow this document exactly; do not use Python features or functions that aren't listed here.
## What not to write
Don't write scripts meant to crash or overload bots or Kyro, get around these limits, or raid, nuke or mass-damage servers (mass deleting channels or roles, mass bans, mass DMs, spam). That breaks Kyro's Terms and can get the bot switched off and the person's account suspended. If asked for one, say no briefly and offer a legitimate version (for example a moderation command for staff).
## How to answer
Reply with **one complete command file** in a single ```kyroscript code block, then one or two sentences on what it does. A command file has the command's settings at the top, a line with just `---`, then the script. The person pastes the whole file into Kyro's editor, which fills in the settings for them.
```kyroscript
command: pay
description: Pay someone coins
arg to: user, required, Who to pay
arg amount: number, required, min 1, How many coins
allow: balances
cooldown: 5
---
if args.to == user:
fail("You can't pay yourself.")
if economy.balance(user) < args.amount:
fail("You don't have {args.amount} coins.")
economy.take(user, args.amount)
economy.give(args.to, args.amount)
reply("{user.mention} paid {args.to.mention} {args.amount} coins.")
```
Settings (one per line, above `---`; leave out any you don't need):
- `command: name`: lowercase letters, numbers, `-` and `_`, up to 32 characters. For an automation, write `event: name` instead (see Events below); automations have no arguments, permissions, roles or mode.
- `description: text`: up to 100 characters, shown in Discord.
- `arg name: type, required|optional, [choices a | b | c], [min N], [max N], description`: one line per argument, up to 10. Types: text, number, user, channel, role, bool. Names are lowercase letters, numbers and `_`. Required arguments come before optional ones. `choices` (text or number) makes Discord show a fixed list; `min`/`max` limit a number's value or a text's length. Put the description in quotes if it has a comma. In the script, each argument is `args.name`.
- `permissions: a, b`: **Discord permissions the person running the command needs** (all of them); Discord also hides the command from people without them. Names: administrator, manage_server, manage_roles, manage_channels, manage_messages, manage_nicknames, manage_threads, manage_events, manage_webhooks, view_audit_log, kick_members, ban_members, moderate_members, mention_everyone, mute_members, deafen_members, move_members, view_channel, send_messages, embed_links, attach_files, add_reactions, use_external_emojis, create_public_threads.
- `roles: Role One, Role Two`: the person needs at least one of these roles (by name).
- `allow: a, b`: **what the script itself is allowed to do** (see Allowed actions below). Required for any function marked "Needs allow: …".
- `cooldown: seconds`: how long each person waits between uses (default 3).
- `mode: slash | prefix | both`: how people use the command (default: the same as the bot's other commands).
Automation files use `event: name` instead of `command: name`, plus `description` (its name in lists), `allow`, `cooldown` (per person, default 0) and these optional filters (an empty filter means "any"):
- `channels: general, memes`: `message` and `reaction_add` only, the channels it runs in.
- `contains: hello, good morning`: `message` only, run when the text contains any of these (any case).
- `emojis: ⭐, 👍`: `reaction_add` only.
- `roles: VIP`: `role_add` and `role_remove` only, which roles it's about.
Don't mix up `permissions` and `allow`: `permissions: manage_messages` limits **who** can run the command; `allow: roles` lets **the script** give and take roles.
## Events (for automations)
- `member_join`: A member joins. `user` and `member` are the person who joined. `channel` is the server’s system channel (or none).
- `member_leave`: A member leaves. `user` is the person who left. `member` has no roles any more. `channel` is the server’s system channel (or none).
- `message`: A message is sent. `message` is the message, `user` its author, `channel` where it was sent.
- `reaction_add`: A reaction is added. `message` is the message, `user` who reacted, `event.emoji` the emoji, `channel` where.
- `role_add`: Someone gets a role. `user` and `member` are who got it, `event.role` the role. `channel` is the system channel (or none).
- `role_remove`: Someone loses a role. `user` and `member` are who lost it, `event.role` the role. `channel` is the system channel (or none).
Automation rules:
- They never run for bots, and changes the bot's own scripts make (roles, kicks, timeouts, bans) never start them, so they can't loop.
- `reply()` only works for `message` and `reaction_add` (it answers that message). For the others, post with `send(get_channel("name"), …)` (needs `allow: channels`) or use `channel` (the server's system channel, which may be none).
- They act as the bot: they can't give or change roles with staff permissions, can't kick or time out staff, and can't ban, unban, purge, delete channels or roles, or change server settings. Write a command for those.
- They can make at most 25 channels, threads and roles per server per day.
- Problems are written to the run log, not posted in the server. Server admins can switch automations off with /modules.
## The most important rules
- Indentation (4 spaces) makes blocks, like Python. Lines that start a block end with `:`.
- `true`, `false` and `none` are lowercase.
- Make functions with `func name(a, b=1):`, not `def`. Functions must be at the top level of the script, not inside if/loops.
- There are **no imports, classes, lambdas, `global`, `with`, `yield`, list comprehensions, slicing syntax (`x[1:3]`), `**`, or methods**. Use the built-in functions instead: `append(items, x)` not `items.append(x)`, `upper(t)` not `t.upper()`, `slice(x, 1, 3)` not `x[1:3]`, `len(x)`.
- Double-quoted text fills in `{…}`: `"Hi {user.name}, you have {coins * 2} coins"`. Single-quoted text is literal. **Inside `{…}`, write any text in single quotes**: `"{join(names, ', ')}"`. To show a brace, write `\{` or `\}`.
- Text joins with anything using `+`: `"Level " + 5` is `"Level 5"`.
- Compare two things at a time: `a < b and b < c`, never `a < b < c`.
- Functions can't be stored in variables or passed around; only call them.
- The starting variables (`user`, `member`, `server`, `channel`, `args`, `message`, `event`) can't be reassigned. Pick other names (`target`, `room`…).
- Built-in names can't be used as variable names (e.g. don't name a variable `text`, `max`, `round`, `reply`).
- Reading a missing map key gives `none` (`m.missing`, `m["missing"]`). Map keys are always text. `m.key` and `m["key"]` mean the same.
- Discord objects (user, member, server, channel, role, message) are read-only: read their fields, pass them to functions.
- To check what someone may do, use `has_permission(member, "kick_members")` or `"kick_members" in member.permissions`. To limit who can run a whole command, use the `permissions:` or `roles:` setting instead of checking in the script.
- `fail("message")` stops the script and shows the message as an error. It can't be caught. `error("message")` raises an error that `try/except` can catch.
- To stop early, use `fail(…)` or an `if/else`; `return` only works inside functions.
- Truthiness is like Python: `0`, `""`, `none`, `false`, `[]` and `{}` are false. `a or b` gives `a` if it's truthy, else `b` (handy for defaults: `target = args.who or user`).
## Syntax
```kyroscript
# comments start with #
name = "Ana" # text
count = 3 # number (whole or decimal)
ok = true # bool
nothing = none
items = [1, 2, 3] # list
info = {"a": 1, "b": "x"} # map (keys are text)
info.c = 5 # same as info["c"] = 5
count += 1 # also -= *= /= //= %=
if count > 2 and not ok:
reply("big")
elif count == 0:
reply("zero")
else:
reply("small")
label = "even" if count % 2 == 0 else "odd"
for item in items: # lists, text (each character) or maps (each key)
if item == 2:
continue
print(item)
for i in range(5): # 0, 1, 2, 3, 4
pass
repeat 3: # do something 3 times
react("🎉")
while count < 10:
count += 1
if count == 7:
break
func greet(person, loud=false):
t = "Hello, {person.name}!"
return upper(t) if loud else t
reply(greet(user, loud=true))
try:
x = 10 / 0
except err:
reply("Problem: {err.message}") # err has .message, .code, .line
```
Operators: `+ - * / // %` (`//` rounds down, `%` is the remainder), `== != < <= > >=`, `and or not`, `in`, `not in` (text contains text, list contains value, map has key). `"ab" * 3` repeats text; `[1] + [2]` joins lists.
## Starting variables
- `user` (user): whoever triggered the script
- `member` (member): the same person as a member of this server (roles, nickname, joined_at)
- `server` (server): this server
- `channel` (channel): the channel it happened in
- `args` (map): the command’s arguments, by name (commands only)
- `message` (message): the message (prefix commands and message automations)
- `event` (map): details of what happened (automations only)
`args.<name>` holds each command argument; optional arguments that weren't given are `none`. A `user` argument gives a user (use `get_member(args.x)` for their roles in this server).
## Fields on Discord objects
- **user**: `id` (text), `name` (text), `display_name` (text), `mention` (text), `avatar` (text), `bot` (bool), `created_at` (number)
- **member**: `id` (text), `name` (text), `display_name` (text), `nickname` (text), `mention` (text), `avatar` (text), `bot` (bool), `created_at` (number), `joined_at` (number), `roles` (list), `permissions` (list), `is_owner` (bool), `status` (text), `activity` (text), `user` (user)
- **server**: `id` (text), `name` (text), `icon` (text), `owner_id` (text), `member_count` (number), `boosts` (number), `boost_level` (number), `channel_count` (number), `role_count` (number), `created_at` (number)
- **channel**: `id` (text), `name` (text), `mention` (text), `type` (text), `topic` (text), `nsfw` (bool)
- **role**: `id` (text), `name` (text), `mention` (text), `color` (text), `position` (number), `member_count` (number)
- **message**: `id` (text), `content` (text), `author` (user), `channel` (channel), `link` (text), `created_at` (number)
- **embed**: `title` (text), `description` (text), `color` (number), `url` (text), `image` (text), `thumbnail` (text), `footer` (text), `author` (text), `fields` (list)
- **error**: `message` (text), `code` (text), `line` (number)
Times (`created_at`, `joined_at`, `now()`) are Unix timestamps in seconds. Users, channels and roles turn into their mention when put in text: `"Hi {user}"` pings them; use `{user.name}` for just the name.
## Built-in functions
`name?` means optional. Optional arguments can also be given by name: `reply("hi", private=true)`.
### Messages and embeds
- `reply(message: any, embed?: embed, private?: bool) → none`: Reply to whoever ran the command (or to the message that triggered the automation). Example: `reply("Hello, {user.name}!")`
- `send(channel: channel|text, message: any, embed?: embed) → none`: Post in a channel (by channel, id or name). *Needs `allow: channels`.* Example: `send(get_channel("logs"), "{user.name} used /hello")`
- `dm(message: any, embed?: embed) → bool`: Send a direct message to the person who triggered the script. Returns false if their DMs are closed. Example: `dm("Thanks for joining!")`
- `react(emoji: text) → none`: React to the triggering message (or the bot’s reply). Example: `react("🎉")`
- `unreact(emoji: text) → none`: Remove the bot’s reaction.
- `embed(title?: text, description?: text, color?: text|number, url?: text, image?: text, thumbnail?: text, footer?: text, author?: text, fields?: list) → embed`: Make an embed to pass to reply, send or dm. Example: `reply(embed(title=server.name, description="Welcome!", color="#7289DA"))`
- `purge(count: number, user?: member|user) → number`: Delete recent messages in this channel (Discord only allows messages under 14 days old). Returns how many were deleted. Needs Manage Messages. Not in automations. *Needs `allow: moderation`.* Example: `n = purge(20)`
- `delete_message() → none`: Delete the message that started the script (a prefix command, or the message or reaction an automation runs on). Great for filters. *Needs `allow: moderation`.* Example: `delete_message()`
- `pin_message(pinned?: bool) → none`: Pin (or unpin) the message that started the script. Needs Manage Messages. *Needs `allow: moderation`.* Example: `pin_message()`
- `create_thread(name: text, on_message?: bool) → channel`: Start a thread in this channel and give it back, so you can send() to it. *Needs `allow: channels`.* Example: `thread = create_thread("Discussion: {args.topic}")`
### Members and roles
- `give_role(member: member|user, role: role|text) → none`: Give someone a role. The bot’s role must be above it, and so must the role of whoever ran the command. *Needs `allow: roles`.* Example: `give_role(member, "Verified")`
- `take_role(member: member|user, role: role|text) → none`: Take a role away. *Needs `allow: roles`.*
- `has_role(member: member|user, role: role|text) → bool`: Whether someone has a role. Example: `if has_role(member, "VIP"):`
- `has_permission(member: member|user, permission: text) → bool`: Whether someone has a server permission (administrators have them all). Example: `if has_permission(member, "manage_messages"):`
- `get_member(user: user|text) → member`: Look up someone in this server. Returns none if they aren’t here.
- `kick(member: member|user, reason?: text) → none`: Kick someone. The person running the command needs Kick Members. *Needs `allow: moderation`.*
- `timeout(member: member|user, minutes: number, reason?: text) → none`: Time someone out (up to 28 days). The person running the command needs Moderate Members. *Needs `allow: moderation`.*
- `ban(user: member|user|text, reason?: text, delete_days?: number) → none`: Ban someone (they don’t have to be in the server). The person running the command needs Ban Members. Not in automations. *Needs `allow: moderation`.* Example: `ban(args.who, "Spam")`
- `unban(user: user|text, reason?: text) → bool`: Lift a ban. Returns false if they weren’t banned. Needs Ban Members. Not in automations. *Needs `allow: moderation`.* Example: `unban(args.id)`
- `set_nickname(member: member|user, nickname?: text) → none`: Change someone’s nickname in this server (none resets it). Needs Manage Nicknames, unless it’s your own and you can change your nickname. *Needs `allow: server`.* Example: `set_nickname(user, "🎉 {user.name}")`
- `create_role(name: text, color?: text, hoist?: bool, mentionable?: bool) → role`: Make a role (with no permissions: give those in Discord). Needs Manage Roles. *Needs `allow: server`.* Example: `r = create_role("Event winner", color="#f1c40f")`
- `edit_role(role: role|text, name?: text, color?: text, hoist?: bool, mentionable?: bool) → none`: Change a role’s name, colour, or whether it’s shown separately or mentionable. Needs Manage Roles, and the role has to be below yours and the bot’s. *Needs `allow: server`.* Example: `edit_role("VIP", color="#9b59b6")`
- `delete_role(role: role|text, reason?: text) → none`: Delete a role for good. Needs Manage Roles. Not in automations. *Needs `allow: server`.* Example: `delete_role("Old event")`
### Server and channels
- `create_channel(name: text, type?: text, category?: channel|text, topic?: text, private?: bool, allow?: list) → channel`: Make a channel. Needs Manage Channels. *Needs `allow: server`.* Example: `room = create_channel("ticket-{user.name}", private=true, allow=[user])`
- `edit_channel(channel: channel|text, name?: text, topic?: text, slowmode?: number, nsfw?: bool, category?: channel|text) → none`: Change a channel’s name, topic, slowmode, age limit or category. Needs Manage Channels. *Needs `allow: server`.* Example: `edit_channel(channel, slowmode=10)`
- `lock_channel(channel?: channel|text, locked?: bool) → none`: Stop @everyone sending messages in a channel (or let them again). Needs Manage Channels. *Needs `allow: server`.* Example: `lock_channel(locked=true)`
- `delete_channel(channel: channel|text, reason?: text) → none`: Delete a channel for good. Needs Manage Channels. Not in automations. *Needs `allow: server`.* Example: `delete_channel(channel)`
- `edit_server(name?: text, verification?: text, system_channel?: channel|text) → none`: Change the server’s name, verification level or system channel. Needs Manage Server. Not in automations. *Needs `allow: server`.* Example: `edit_server(verification="high")`
- `list_channels(type?: text) → list`: The server’s channels (up to 100), in order. Example: `for c in list_channels("text"):
print(c.name)`
- `list_roles() → list`: The server’s roles (up to 100), highest first. Example: `top = list_roles()[0]`
- `get_channel(channel: text) → channel`: Find a channel in this server. Returns none if there isn’t one.
- `get_role(role: text) → role`: Find a role in this server. Returns none if there isn’t one.
- `config.get(key: text) → any`: Read one of the bot’s settings.
### Economy (`economy.*`)
- `economy.balance(user: user|member) → number`: Coins in someone’s wallet. Example: `coins = economy.balance(user)`
- `economy.bank(user: user|member) → number`: Coins in someone’s bank.
- `economy.give(user: user|member, amount: number, reason?: text) → number`: Add coins to someone’s wallet. Returns their new balance. *Needs `allow: balances`.* Example: `economy.give(user, 100, "daily reward")`
- `economy.take(user: user|member, amount: number, reason?: text) → number`: Take coins from someone’s wallet. Fails if they don’t have enough. Returns their new balance. *Needs `allow: balances`.*
- `economy.top(limit?: number) → list`: The richest members here (up to 25): a list of maps with "user" and "coins".
### Levels (`levels.*`)
- `levels.xp(user: user|member) → number`: Someone’s XP in this server.
- `levels.level(user: user|member) → number`: Someone’s level in this server. Example: `level = levels.level(user)`
- `levels.rank(user: user|member) → number`: Someone’s position on the leaderboard (1 = top).
- `levels.add_xp(user: user|member, amount: number) → number`: Give (or take) XP. Level-up messages and role rewards still happen. Returns their new XP. *Needs `allow: xp`.*
### Storage (`storage.*`)
- `storage.get(key: text, default?: any, user?: user|member, shared?: bool) → any`: Read a saved value (or the default if there isn’t one). Example: `visits = storage.get("visits", 0)`
- `storage.set(key: text, value: any, user?: user|member, shared?: bool) → none`: Save a value: text, a number, true/false, a list or a map. *Needs `allow: storage`.* Example: `storage.set("visits", visits + 1)`
- `storage.add(key: text, amount?: number, user?: user|member, shared?: bool) → number`: Add to a saved number (1 by default) and return the new total. Safe when two people run it at once. *Needs `allow: storage`.* Example: `count = storage.add("uses")`
- `storage.delete(key: text, user?: user|member, shared?: bool) → none`: Delete a saved value. *Needs `allow: storage`.*
### Text
- `text(value: any) → text`: Turn anything into text.
- `upper(text: text) → text`: UPPERCASE.
- `lower(text: text) → text`: lowercase.
- `trim(text: text) → text`: Remove spaces from both ends.
- `split(text: text, separator?: text) → list`: Split text into a list. Example: `words = split("a b c")`
- `join(list: list, separator?: text) → text`: Join a list into text. Example: `join(names, ", ")`
- `replace(text: text, find: text, with: text) → text`: Replace every match.
- `starts_with(text: text, start: text) → bool`: Whether text starts with something.
- `ends_with(text: text, end: text) → bool`: Whether text ends with something.
- `find(text: text, part: text) → number`: Where something first appears in text (0 = the start), or -1.
### Math
- `number(value: text|number|bool) → number`: Turn text into a number. Returns none if it isn’t one. Example: `amount = number(args.amount)`
- `round(number: number, decimals?: number) → number`: Round to the nearest whole number (or to some decimals).
- `floor(number: number) → number`: Round down.
- `ceil(number: number) → number`: Round up.
- `abs(number: number) → number`: Remove the minus sign.
- `min(numbers: number|list, …) → number`: The smallest of some numbers (or of a list). Example: `min(5, 3, 9)`
- `max(numbers: number|list, …) → number`: The largest of some numbers (or of a list).
- `sum(list: list) → number`: Add up a list of numbers.
- `random(low: number, high: number) → number`: A random whole number from low to high (both included). Example: `roll = random(1, 6)`
### Lists and maps
- `len(value: text|list|map) → number`: How long text is, or how many items a list or map has.
- `contains(in: text|list|map, value: any) → bool`: Whether text contains some text, a list contains a value, or a map has a key. Same as “value in thing”.
- `append(list: list, value: any) → none`: Add a value to the end of a list.
- `remove(list: list, value: any) → bool`: Remove the first matching value. Returns whether one was found.
- `pop(list: list) → any`: Remove and return the last item (none if empty).
- `sort(list: list, reverse?: bool) → list`: A sorted copy of a list of numbers or of text.
- `reverse(list: list) → list`: A reversed copy of a list.
- `shuffle(list: list) → list`: A shuffled copy of a list.
- `choice(list: list) → any`: A random item from a list. Example: `choice(["rock", "paper", "scissors"])`
- `range(start: number, end?: number, step?: number) → list`: Numbers counting up: range(5) is [0, 1, 2, 3, 4], range(1, 4) is [1, 2, 3].
- `slice(value: text|list, start: number, end?: number) → any`: Part of some text or a list, from start up to (not including) end. Negative numbers count from the end.
- `keys(map: map) → list`: A map’s keys, as a list.
- `values(map: map) → list`: A map’s values, as a list.
- `get(map: map, key: text, default?: any) → any`: A map’s value for a key, or the default if it isn’t there.
### Types
- `type_of(value: any) → text`: What kind of value something is: "number", "text", "list", "user"…
### Time
- `now() → number`: The current time, in seconds since 1970 (a Unix timestamp).
- `format_time(time: number, style?: text) → text`: A time that shows in each reader’s own time zone. Example: `reply("Ends {format_time(now() + 3600)}")`
- `wait(seconds: number) → none`: Pause for a moment (up to 10 seconds in total per run). Example: `wait(2)`
### Errors and debugging
- `fail(message: text) → none`: Stop right here and show the message as an error. Can’t be caught by try/except. Example: `fail("You need at least 100 coins.")`
- `error(message: text) → none`: Raise an error that a try/except around it can catch.
- `print(values: any, …) → none`: Write a line to the test runner and the run log (not to Discord).
### Internet
- `integrations.weather(place: text) → map`: The weather right now somewhere: place, country, temp_c, temp_f, feels_like_c, humidity, wind_kph, condition and emoji. none if the place isn’t found. *Needs `allow: internet`.* Example: `w = integrations.weather("London")`
- `integrations.define(word: text) → map`: An English dictionary entry: word, phonetic and meanings (a list of maps with part, definition and example). none if it isn’t found. *Needs `allow: internet`.* Example: `d = integrations.define("serendipity")`
- `integrations.wikipedia(topic: text) → map`: A short Wikipedia summary: title, summary, url and image. none if there’s no article. *Needs `allow: internet`.* Example: `w = integrations.wikipedia("Octopus")`
- `integrations.crypto_price(coin: text, currency?: text) → map`: A coin’s price: coin, currency, price and change_24h (percent). none if the coin isn’t found. *Needs `allow: internet`.* Example: `p = integrations.crypto_price("bitcoin")`
- `integrations.steam_game(name: text) → map`: A game on Steam: name, price (text), free, url, image and metacritic. none if it isn’t found. *Needs `allow: internet`.* Example: `g = integrations.steam_game("Hades")`
- `secret(name: text) → secret`: An API key you saved in the dashboard. It can only be put in http request headers or query values, and only for the site it’s tied to: scripts can never read it. Max only. *Needs `allow: internet`.* Example: `key = secret("WEATHER_KEY")`
- `http.get(url: text, headers?: map, query?: map) → map`: Fetch a page from a site in your allowlist. Gives a map with status, ok, json (if the answer was JSON) and text. Max only. *Needs `allow: internet`.* Example: `r = http.get("https://api.example.com/stats", query={"id": "123"})`
- `http.post(url: text, json?: any, headers?: map, query?: map) → map`: Send JSON to a site in your allowlist. Gives a map with status, ok, json and text, like http.get. Max only. *Needs `allow: internet`.* Example: `r = http.post("https://api.example.com/scores", json={"user": user.id, "score": 10})`
## Allowed actions (the `allow:` line)
A script can only use these functions if the action is on its `allow:` line; otherwise it won't save.
- `roles` (“Give and take roles”): give_role, take_role
- `moderation` (“Moderate members and messages”): kick, timeout, ban, unban, purge, delete_message, pin_message (the person running the command needs the same permission)
- `server` (“Change the server”): create, edit and delete channels and roles, lock channels, nicknames and server settings (the person running the command needs the same permission)
- `channels` (“Post in other channels”): send to a channel other than the current one
- `mentions` (“Ping @everyone, @here and roles”): without this, mass pings are removed from messages
- `balances` (“Change balances”): economy.give, economy.take
- `xp` (“Change XP”): levels.add_xp
- `storage` (“Save data”): storage.set, storage.add, storage.delete
- `internet` (“Use the internet”): integrations.* and http.*
## Limits (per run)
| | Pro | Max |
| --- | --- | --- |
| Steps (each line/value worked out) | 20,000 | 50,000 |
| Time | 3 s | 5 s |
| Discord actions (reply, send, roles, reactions…) | 10 | 20 |
| Storage reads + writes | 30 | 60 |
| Loop length | 1,000 times | 1,000 times |
| Functions calling functions | 32 deep | 32 deep |
| `wait()` in total | 10 s | 10 s |
| Script length | 20,000 characters | 50,000 characters |
| Internet requests | 2 | 4 |
| Internet requests per bot per day | 1,000 | 10,000 |
Text can be up to 100,000 characters, lists and maps up to 10,000 items. Discord messages are cut at 2,000 characters. Keep scripts simple: avoid big loops and repeated Discord calls inside loops.
## Internet
Needs `allow: internet`. `integrations.*` work on Pro and Max with no setup and return a map, or `none` when nothing is found. `http.get`, `http.post` and `secret` are **Max only** and can only reach **HTTPS sites the owner added to the bot's allowlist** in the dashboard (Scripts → Internet). Never put an API key in a script: the owner saves it there as a secret, and the script uses `secret("NAME")` as a header or query value. A secret can't be printed, saved, or sent to any site but its own. Check `r.ok` (or `r.status`) before using `r.json`. Test runs in the editor don't go online; they return a pretend answer.
## Changing the server
Needs `allow: server` (channels, roles, nicknames, server settings) or `allow: moderation` (kick, timeout, ban, unban, purge, delete_message, pin_message). The person running the command needs the matching Discord permission too (the server owner always can), and roles can only be changed below both their top role and the bot's. New roles never get permissions.
## Errors
Errors show the line number. Common ones: an unknown name (typo, or a variable used before it's set), an action missing from `allow:`, the wrong type passed to a function ("give_role: role must be a role or a text, but got a number"), and hitting a limit. Limits and `fail()` can't be caught with `try/except`.
## Examples
### Say hello
The smallest possible command: reply with the person’s name.
```kyroscript
command: hello
description: Say hello
---
reply("Hello, {user.display_name}! 👋")
```
### Check a balance
An optional argument with a fallback: your own balance, or someone else’s.
```kyroscript
command: balance
description: See how many coins someone has
arg who: user, optional, Whose balance (default: you)
---
# use the person picked, or whoever ran the command
target = args.who or user
coins = economy.balance(target)
reply("{target.display_name} has {coins} {config.get('currency_name')}.")
```
### Server info card
An embed built from the server’s details.
```kyroscript
command: serverinfo
description: Show info about this server
---
card = embed(
title=server.name,
description="Welcome to our server!",
color="#7289DA",
fields=[
{"name": "Members", "value": text(server.member_count), "inline": true},
{"name": "Boosts", "value": text(server.boosts), "inline": true},
{"name": "Created", "value": format_time(server.created_at, "date"), "inline": true},
],
)
reply(card)
```
### VIP reward
Check for a role, then pay out coins or explain why not.
```kyroscript
command: reward
description: Claim the VIP reward
allow: balances
---
if has_role(member, "VIP"):
new = economy.give(user, 100, "VIP reward")
reply("💎 Enjoy 100 coins! You now have {new}.")
else:
reply("This reward is for VIPs only.", private=true)
```
### Daily reward with a cooldown
Remember when each person last claimed, using storage per member.
```kyroscript
command: daily
description: Claim your daily coins
allow: balances, storage
---
last = storage.get("last_daily", 0, user=member)
next_time = last + 86400
if now() < next_time:
fail("You already claimed today. Come back {format_time(next_time)}.")
streak = storage.add("streak", 1, user=member)
amount = 50 + min(streak, 10) * 10
economy.give(user, amount, "daily")
storage.set("last_daily", now(), user=member)
reply("🎁 +{amount} coins! Streak: {streak} day{'' if streak == 1 else 's'}.")
```
### Magic 8-ball
A random answer from a list.
```kyroscript
command: 8ball
description: Ask the magic 8-ball
arg question: text, required, Ask anything
---
answers = ["Yes!", "No.", "Maybe…", "Ask again later.", "Definitely.", "I wouldn’t count on it."]
reply("🎱 **{args.question}**\n{choice(answers)}")
```
### Dice roller
A number argument with checks.
```kyroscript
command: roll
description: Roll a dice
arg sides: number, optional, min 2, max 1000, How many sides (default 6)
---
# Discord only lets people pick 2 to 1000 (the min and max on the argument)
sides = args.sides or 6
reply("🎲 You rolled **{random(1, sides)}** (d{sides}).")
```
### Visit counter
A number that remembers between runs.
```kyroscript
command: visit
description: Count visits
allow: storage
---
count = storage.add("visits")
reply("You’re visitor number **{count}**!")
```
### Pay someone
Move coins between two people, with every check a real command needs.
```kyroscript
command: pay
description: Pay someone coins
arg to: user, required, Who to pay
arg amount: number, required, min 1, How many coins
allow: balances
---
amount = floor(args.amount)
if args.to == user:
fail("You can’t pay yourself.")
if economy.balance(user) < amount:
fail("You don’t have {amount} coins.")
economy.take(user, amount, "pay to {args.to.name}")
economy.give(args.to, amount, "pay from {user.name}")
reply("💸 {user.mention} paid {args.to.mention} **{amount}** coins.")
```
### Richest members
Loop over a list and build a leaderboard.
```kyroscript
command: richest
description: See the richest members
---
lines = []
place = 1
for row in economy.top(5):
medal = ["🥇", "🥈", "🥉"][place - 1] if place <= 3 else "{place}."
append(lines, "{medal} {row.user.display_name}: {row.coins}")
place += 1
reply(embed(title="Richest members", description=join(lines, "\n") or "Nobody has coins yet."))
```
### Level progress bar
A reusable function that draws a progress bar from XP.
```kyroscript
command: progress
description: See your level progress
---
func bar(fraction, width=10):
filled = round(fraction * width)
return "▰" * filled + "▱" * (width - filled)
# XP needed to reach a level
func needed(lvl):
return lvl * lvl * 100
level = levels.level(user)
xp = levels.xp(user)
start = needed(level)
finish = needed(level + 1)
fraction = (xp - start) / (finish - start)
reply("Level **{level}** (rank #{levels.rank(user)})\n{bar(fraction)} {xp - start}/{finish - start} XP")
```
### Personal to-do list
A list kept in storage for each person, with add, done and show.
```kyroscript
command: todo
description: Your personal to-do list
arg action: text, required, choices add | done | show, What to do
arg item: text, optional, "What to add, or the number to tick off"
allow: storage
---
items = storage.get("todo", [], user=member)
action = args.action
if action == "add":
if not args.item:
fail("What should I add? Use /todo add <item>.")
if len(items) >= 25:
fail("Your list is full (25 items).")
append(items, args.item)
reply("Added: {args.item}", private=true)
elif action == "done":
n = number(args.item or "")
if n == none or n < 1 or n > len(items):
fail("Give the number of the item to tick off.")
finished = items[n - 1]
remove(items, finished)
reply("✅ Done: {finished}", private=true)
else:
shown = []
i = 1
for it in items:
append(shown, "{i}. {it}")
i += 1
reply(join(shown, "\n") or "Your list is empty.", private=true)
storage.set("todo", items, user=member)
```
### Verify button-free
Give a role and send a DM, handling closed DMs.
```kyroscript
command: verify
description: Verify yourself
allow: roles
---
if has_role(member, "Verified"):
fail("You’re already verified.")
give_role(member, "Verified")
if not dm("Welcome to {server.name}! You can see every channel now."):
reply("✅ Verified! (Your DMs are closed, so I couldn’t message you.)", private=true)
else:
reply("✅ Verified! Check your DMs.", private=true)
```
### Rock, paper, scissors
Maps as lookup tables.
```kyroscript
command: rps
description: Play rock, paper, scissors
arg pick: text, required, "rock, paper or scissors"
---
beats = {"rock": "scissors", "paper": "rock", "scissors": "paper"}
mine = lower(trim(args.pick))
if mine not in beats:
fail("Pick rock, paper or scissors.")
theirs = choice(keys(beats))
if mine == theirs:
result = "It’s a tie!"
elif beats[mine] == theirs:
result = "You win! 🎉"
else:
result = "I win! 😎"
reply("You: {mine} · Me: {theirs}\n**{result}**")
```
### Warnings that add up
Count warnings per member and time them out on the third.
```kyroscript
command: strike
description: Give someone a strike
arg who: user, required, Who to warn
arg reason: text, optional, Why
permissions: moderate_members
allow: storage, moderation
---
# only people with Timeout Members can run this (the permissions: setting)
target = get_member(args.who)
if target == none:
fail("They’re not in this server.")
strikes = storage.add("strikes", 1, user=target)
why = args.reason or "no reason given"
if strikes >= 3:
timeout(target, 60, "3 strikes: {why}")
storage.delete("strikes", user=target)
reply("⛔ {target.mention} got their 3rd strike and is timed out for an hour.")
else:
reply("⚠️ Strike {strikes}/3 for {target.mention}: {why}")
```
### Staff announcement
A staff-only command: Discord permissions decide who can run it, a channel argument decides where it posts.
```kyroscript
command: announce
description: Post an announcement
arg where: channel, required, Which channel
arg text: text, required, max 1500, What to say
arg title: text, optional, A title (optional)
permissions: manage_server
allow: channels
---
card = embed(
title=args.title or "📣 Announcement",
description=args.text,
footer="From {user.display_name}",
)
send(args.where, card)
reply("Posted in {args.where}.", private=true)
```
### Catching errors
try/except turns a problem into a friendly message.
```kyroscript
command: split
description: Split a bill
arg total: number, required, The bill
arg people: number, required, How many people
---
try:
each = round(args.total / args.people, 2)
reply("That’s **{each}** each.")
except err:
reply("I couldn’t work that out: {err.message}", private=true)
```
### Welcome message (automation)
Runs by itself when someone joins: post a welcome in a channel.
```kyroscript
event: member_join
description: Welcome new members
allow: channels
---
room = get_channel("welcome")
if room != none:
send(room, "Welcome {user.mention}! You’re member #{server.member_count} 🎉")
```
### Weather (internet)
A built-in integration: no keys or setup, on Pro and Max.
```kyroscript
command: weather
description: Check the weather anywhere
arg place: text, required, A city or place
allow: internet
---
w = integrations.weather(args.place)
if w == none:
fail("I couldn’t find {args.place}.")
card = embed(
title="{w.emoji} Weather in {w.place}, {w.country}",
description="{w.condition}, {w.temp_c}°C ({w.temp_f}°F). Feels like {w.feels_like_c}°C.",
fields=[
{"name": "Humidity", "value": "{w.humidity}%", "inline": true},
{"name": "Wind", "value": "{w.wind_kph} km/h", "inline": true},
],
)
reply(card)
```
### Your own API (internet, Max)
http.get on a site you added to your allowlist, with an API key kept as a secret.
```kyroscript
command: stats
description: Look up a player on your game’s site
arg player: text, required, Player name
allow: internet
---
# api.example.com must be in your allowlist, and GAME_KEY saved as a secret for it
r = http.get(
"https://api.example.com/players",
query={"name": args.player},
headers={"Authorization": secret("GAME_KEY")},
)
if not r.ok:
fail("The game site said no ({r.status}).")
reply("📊 {args.player}: {r.json}")
```
### Support ticket
Makes a private channel only you and the staff role can see.
```kyroscript
command: ticket
description: Open a private support ticket
permissions: manage_channels
allow: server, channels
---
room = create_channel("ticket-{user.name}", private=true, allow=[user, "Moderator"])
send(room, "Hi {user.mention}! Tell us what you need and a moderator will be with you soon.")
reply("Your ticket is open: {room.mention}", private=true)
```
### Link filter (automation)
Deletes messages with links unless the author can manage messages.
```kyroscript
event: message
description: Delete links from non-staff
allow: moderation
contains: http://, https://
---
if not has_permission(member, "manage_messages"):
delete_message()
dm("Links aren’t allowed in {server.name}, so your message was removed.")
```
### Role for new members (automation)
Everyone who joins gets the Member role. Bots never trigger automations.
```kyroscript
event: member_join
description: Give new members a role
allow: roles
---
give_role(member, "Member")
```
### Goodbye message (automation)
Post in a channel when someone leaves the server.
```kyroscript
event: member_leave
description: Say goodbye
allow: channels
---
room = get_channel("welcome")
if room != none:
send(room, "{user.name} left. We’re {server.member_count} now.")
```
### Keyword reply (automation)
When a message mentions “server rules”, reply with where to find them.
```kyroscript
event: message
description: Answer a question
contains: server rules
---
reply("📜 The rules are pinned in #rules, {user.display_name}.")
```
### Star counter (automation)
Every ⭐ reaction gives the message’s author a point, saved for later.
```kyroscript
event: reaction_add
description: Count stars
allow: storage
emojis: ⭐
---
author = message.author
if author.id != user.id:
stars = storage.add("stars", 1, user=author)
print("{author.name} now has {stars} stars")
react("✅")
```
### Announce new VIPs (automation)
When someone gets the VIP role, celebrate it in #announcements.
```kyroscript
event: role_add
description: Announce new VIPs
allow: channels
roles: VIP
---
send(get_channel("announcements"), "🎉 Welcome to the VIP club, {user.mention}!")
```
✨ Tip Always run the AI’s script with Test before publishing. If the editor shows an error, paste the error back to the AI and ask it to fix it.
Was this page helpful?