Examples
Complete command files you can copy: the settings on top, the script below ---. Paste one into the editor and it fills in everything. We test every one of them automatically, so they always work.
Say hello
The smallest possible command: reply with the person’s name.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
event: role_add
description: Announce new VIPs
allow: channels
roles: VIP
---
send(get_channel("announcements"), "🎉 Welcome to the VIP club, {user.mention}!")