Docs
Dashboard
KyroScript

Conditions and loops

if, elif, else

Lines indented under an if only run when its condition is true. Indent with 4 spaces, and end the line before with :.

Script
coins = economy.balance(user)
if coins >= 1000:
    reply("You’re rich!")
elif coins > 0:
    reply("Getting there.")
else:
    reply("You’re broke.")

Comparisons: == (equal), != (not equal), < <= > >=, and in / not in (text contains text, a list contains a value, a map has a key). Combine them with and, or and not.

Script
coins = economy.balance(user)
if has_role(member, "VIP") and "spam" not in args.note:
    reply("Welcome, VIP!")

label = "even" if coins % 2 == 0 else "odd"   # a one-line if
target = args.who or user                     # use args.who, or user if it’s empty
✨ Tip Empty things count as false: 0, "", none, [] and {}. That’s why args.who or user picks user when no one was given.

Loops

Script
repeat 3:
    react("🎉")

for name in ["Ana", "Bo", "Cy"]:
    reply("Hi {name}")

for i in range(5):     # 0, 1, 2, 3, 4
    pass

tries = 0
while tries < 3:
    tries += 1

for goes over a list, each character of some text, or each key of a map. break leaves a loop early and continue skips to the next round.

⚠️ Heads up A loop can run at most 1,000 times, and every run has a step limit, so a loop that never ends just stops with an error instead of freezing your bot.
Was this page helpful?