Docs
Dashboard
KyroScript

Commands, arguments and events

Command settings

In the dashboard you fill these in on the command’s settings panel. In a command file they’re the lines above ---, one per line. Paste a whole file into the code editor and the settings at the top are moved into the settings panel for you, so files from these docs, an AI or a friend just work. Copy file in the editor does the reverse, for sharing.

SettingWhat it is
command: nameThe command people type, like /pay. Lowercase letters, numbers, - and _, up to 32 characters.
description: …The short explanation Discord shows under the command (up to 100 characters).
arg name: type, required, descriptionOne line per argument, up to 10. Types: text, number, user, channel, role, bool. Write required or optional; required ones come first. Text and number arguments can also have choices a | b | c (Discord shows a list to pick from) or min/max.
permissions: kick_membersWho can run it: the Discord permissions the person needs. Discord hides the command from everyone else.
roles: VIP, ModeratorWho can run it: people with at least one of these roles.
allow: balances, storageWhat the script is allowed to do, like change coins or save data. See allowed actions.
cooldown: 5Seconds each person waits between uses (default 3).
mode: bothslash, prefix or both. Leave it out to match your bot’s other commands.

Starting variables

Every script starts with a few variables already set, describing who ran it and where:

  • user: whoever triggered the script.
  • member: the same person as a member of this server (roles, nickname, joined_at).
  • server: this server.
  • channel: the channel it happened in.
  • args: the command’s arguments, by name (commands only).
  • message: the message (prefix commands and message automations).
  • event: details of what happened (automations only).

Arguments

Each argument you add in the settings is args.name in the script. An optional argument nobody filled in is none.

Command file
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.")

What you can read

ThingDetails you can read
userid, name, display_name, mention, avatar, bot, created_at
memberid, name, display_name, nickname, mention, avatar, bot, created_at, joined_at, roles, permissions, is_owner, status, activity, user
serverid, name, icon, owner_id, member_count, boosts, boost_level, channel_count, role_count, created_at
channelid, name, mention, type, topic, nsfw
roleid, name, mention, color, position, member_count
messageid, content, author, channel, link, created_at
embedtitle, description, color, url, image, thumbnail, footer, author, fields
errormessage, code, line

Times (created_at, joined_at, now()) are in seconds since 1970. Turn them into a nice time with format_time(). A person, channel or role put in text becomes a mention: "Hi {user}" pings them, "{user.name}" just shows the name.

Automations

An automation is a script that runs by itself when something happens, instead of when someone types a command. Make one in Scripts → Automations. Its file says event: instead of command:, and it has no arguments, permissions or mode. Instead of args, it gets event with the details.

SettingWhat it is
event: messageWhat it runs on (the events are below).
description: …Its name in your lists and in /modules automations.
channels: general, memesMessages and reactions: only in these channels.
contains: hello, good morningMessages: only when the text contains one of these (any case).
emojis: ⭐, 👍Reactions: only these emojis.
roles: VIPRole events: only these roles.
cooldown: 30Seconds before it runs again for the same person (default 0).
allow: …What the script may do, like commands.

Automations are built so they can’t cause trouble:

  • They never run for bots, and changes your bot’s own scripts make (roles, kicks, timeouts, bans) never start them, so they can’t set each other off in a loop. One that runs too often in a server pauses itself for a minute.
  • They act as the bot, with nobody to check: they can’t give out roles with staff permissions, kick or time out staff, ban, purge, delete channels or roles, or change server settings. Use a command for those.
  • They can make at most 25 channels, threads and roles per server per day.
  • reply() answers the message for message and reaction automations. The others post with send().
  • Problems go to the run log, never into the server.
  • Server admins can turn all automations off with /modules, or one at a time with /modules automations.
✨ Tip Member events need the Server Members intent, and reading messages needs Message Content. Switch them on in the Discord Developer Portal; the editor warns you if one is off.
EventWhenWhat the script gets
member_joinA member joinsuser and member are the person who joined. channel is the server’s system channel (or none).
member_leaveA member leavesuser is the person who left. member has no roles any more. channel is the server’s system channel (or none).
messageA message is sentmessage is the message, user its author, channel where it was sent.
reaction_addA reaction is addedmessage is the message, user who reacted, event.emoji the emoji, channel where.
role_addSomeone gets a roleuser and member are who got it, event.role the role. channel is the system channel (or none).
role_removeSomeone loses a roleuser and member are who lost it, event.role the role. channel is the system channel (or none).
Command file
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} 🎉")
Was this page helpful?