Function reference
Every built-in function. name? means optional. Optional values can be given by name, like reply("hi", private=true).
Messages and embeds
reply(message: any, embed?: embed, private?: bool) → noneReply to whoever ran the command (or to the message that triggered the automation).
message: text, a number or an embedprivate: only the person who ran it sees it (slash commands)
reply("Hello, {user.name}!")send(channel: channel|text, message: any, embed?: embed) → noneNeeds allow: channelsPost in a channel (by channel, id or name).
send(get_channel("logs"), "{user.name} used /hello")dm(message: any, embed?: embed) → boolSend a direct message to the person who triggered the script. Returns false if their DMs are closed.
dm("Thanks for joining!")react(emoji: text) → noneReact to the triggering message (or the bot’s reply).
react("🎉")unreact(emoji: text) → noneRemove the bot’s reaction.
embed(title?: text, description?: text, color?: text|number, url?: text, image?: text, thumbnail?: text, footer?: text, author?: text, fields?: list) → embedMake an embed to pass to reply, send or dm.
color: "#7289DA" or a name like "blue"fields: a list of maps: {"name": …, "value": …, "inline": true}
reply(embed(title=server.name, description="Welcome!", color="#7289DA"))purge(count: number, user?: member|user) → numberNeeds allow: moderationDelete recent messages in this channel (Discord only allows messages under 14 days old). Returns how many were deleted. Needs Manage Messages. Not in automations.
count: 1–100user: only their messages
n = purge(20)delete_message() → noneNeeds allow: moderationDelete the message that started the script (a prefix command, or the message or reaction an automation runs on). Great for filters.
delete_message()pin_message(pinned?: bool) → noneNeeds allow: moderationPin (or unpin) the message that started the script. Needs Manage Messages.
pinned: false unpins
pin_message()create_thread(name: text, on_message?: bool) → channelNeeds allow: channelsStart a thread in this channel and give it back, so you can send() to it.
on_message: start it on the message that started the script
thread = create_thread("Discussion: {args.topic}")Members and roles
give_role(member: member|user, role: role|text) → noneNeeds allow: rolesGive someone a role. The bot’s role must be above it, and so must the role of whoever ran the command.
role: a role, its id or its name
give_role(member, "Verified")take_role(member: member|user, role: role|text) → noneNeeds allow: rolesTake a role away.
has_role(member: member|user, role: role|text) → boolWhether someone has a role.
if has_role(member, "VIP"):has_permission(member: member|user, permission: text) → boolWhether someone has a server permission (administrators have them all).
permission: like "manage_messages", "ban_members", "administrator"
if has_permission(member, "manage_messages"):get_member(user: user|text) → memberLook up someone in this server. Returns none if they aren’t here.
user: a user or their id
kick(member: member|user, reason?: text) → noneNeeds allow: moderationKick someone. The person running the command needs Kick Members.
timeout(member: member|user, minutes: number, reason?: text) → noneNeeds allow: moderationTime someone out (up to 28 days). The person running the command needs Moderate Members.
ban(user: member|user|text, reason?: text, delete_days?: number) → noneNeeds allow: moderationBan someone (they don’t have to be in the server). The person running the command needs Ban Members. Not in automations.
user: a person or their iddelete_days: delete their messages from the last 0–7 days
ban(args.who, "Spam")unban(user: user|text, reason?: text) → boolNeeds allow: moderationLift a ban. Returns false if they weren’t banned. Needs Ban Members. Not in automations.
user: a person or their id
unban(args.id)set_nickname(member: member|user, nickname?: text) → noneNeeds allow: serverChange someone’s nickname in this server (none resets it). Needs Manage Nicknames, unless it’s your own and you can change your nickname.
nickname: none resets it
set_nickname(user, "🎉 {user.name}")create_role(name: text, color?: text, hoist?: bool, mentionable?: bool) → roleNeeds allow: serverMake a role (with no permissions: give those in Discord). Needs Manage Roles.
color: like #ff8800hoist: show members separately
r = create_role("Event winner", color="#f1c40f")edit_role(role: role|text, name?: text, color?: text, hoist?: bool, mentionable?: bool) → noneNeeds allow: serverChange 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.
edit_role("VIP", color="#9b59b6")delete_role(role: role|text, reason?: text) → noneNeeds allow: serverDelete a role for good. Needs Manage Roles. Not in automations.
delete_role("Old event")Server and channels
create_channel(name: text, type?: text, category?: channel|text, topic?: text, private?: bool, allow?: list) → channelNeeds allow: serverMake a channel. Needs Manage Channels.
type: text (default), voice or categorycategory: the category to put it inprivate: hide it from @everyoneallow: members and roles who can see a private channel
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) → noneNeeds allow: serverChange a channel’s name, topic, slowmode, age limit or category. Needs Manage Channels.
slowmode: seconds between messages (0 turns it off)
edit_channel(channel, slowmode=10)lock_channel(channel?: channel|text, locked?: bool) → noneNeeds allow: serverStop @everyone sending messages in a channel (or let them again). Needs Manage Channels.
channel: this channel if left outlocked: false unlocks
lock_channel(locked=true)delete_channel(channel: channel|text, reason?: text) → noneNeeds allow: serverDelete a channel for good. Needs Manage Channels. Not in automations.
delete_channel(channel)edit_server(name?: text, verification?: text, system_channel?: channel|text) → noneNeeds allow: serverChange the server’s name, verification level or system channel. Needs Manage Server. Not in automations.
verification: none, low, medium, high or highestsystem_channel: where Discord posts join messages
edit_server(verification="high")list_channels(type?: text) → listThe server’s channels (up to 100), in order.
type: text, voice or category
for c in list_channels("text"):
print(c.name)list_roles() → listThe server’s roles (up to 100), highest first.
top = list_roles()[0]get_channel(channel: text) → channelFind a channel in this server. Returns none if there isn’t one.
channel: id or name
get_role(role: text) → roleFind a role in this server. Returns none if there isn’t one.
role: id or name
config.get(key: text) → anyRead one of the bot’s settings.
key: "currency", "currency_name", "prefix", "bot_name"
Economy
economy.balance(user: user|member) → numberCoins in someone’s wallet.
coins = economy.balance(user)economy.bank(user: user|member) → numberCoins in someone’s bank.
economy.give(user: user|member, amount: number, reason?: text) → numberNeeds allow: balancesAdd coins to someone’s wallet. Returns their new balance.
economy.give(user, 100, "daily reward")economy.take(user: user|member, amount: number, reason?: text) → numberNeeds allow: balancesTake coins from someone’s wallet. Fails if they don’t have enough. Returns their new balance.
economy.top(limit?: number) → listThe richest members here (up to 25): a list of maps with "user" and "coins".
Levels
levels.xp(user: user|member) → numberSomeone’s XP in this server.
levels.level(user: user|member) → numberSomeone’s level in this server.
level = levels.level(user)levels.rank(user: user|member) → numberSomeone’s position on the leaderboard (1 = top).
levels.add_xp(user: user|member, amount: number) → numberNeeds allow: xpGive (or take) XP. Level-up messages and role rewards still happen. Returns their new XP.
amount: negative to take XP away
Storage
storage.get(key: text, default?: any, user?: user|member, shared?: bool) → anyRead a saved value (or the default if there isn’t one).
user: keep a separate value per personshared: the same value in every server
visits = storage.get("visits", 0)storage.set(key: text, value: any, user?: user|member, shared?: bool) → noneNeeds allow: storageSave a value: text, a number, true/false, a list or a map.
storage.set("visits", visits + 1)storage.add(key: text, amount?: number, user?: user|member, shared?: bool) → numberNeeds allow: storageAdd to a saved number (1 by default) and return the new total. Safe when two people run it at once.
count = storage.add("uses")storage.delete(key: text, user?: user|member, shared?: bool) → noneNeeds allow: storageDelete a saved value.
Text
text(value: any) → textTurn anything into text.
upper(text: text) → textUPPERCASE.
lower(text: text) → textlowercase.
trim(text: text) → textRemove spaces from both ends.
split(text: text, separator?: text) → listSplit text into a list.
separator: default: any spaces
words = split("a b c")join(list: list, separator?: text) → textJoin a list into text.
join(names, ", ")replace(text: text, find: text, with: text) → textReplace every match.
starts_with(text: text, start: text) → boolWhether text starts with something.
ends_with(text: text, end: text) → boolWhether text ends with something.
find(text: text, part: text) → numberWhere something first appears in text (0 = the start), or -1.
Math
number(value: text|number|bool) → numberTurn text into a number. Returns none if it isn’t one.
amount = number(args.amount)round(number: number, decimals?: number) → numberRound to the nearest whole number (or to some decimals).
floor(number: number) → numberRound down.
ceil(number: number) → numberRound up.
abs(number: number) → numberRemove the minus sign.
min(numbers: number|list, …) → numberThe smallest of some numbers (or of a list).
min(5, 3, 9)max(numbers: number|list, …) → numberThe largest of some numbers (or of a list).
sum(list: list) → numberAdd up a list of numbers.
random(low: number, high: number) → numberA random whole number from low to high (both included).
roll = random(1, 6)Lists and maps
len(value: text|list|map) → numberHow long text is, or how many items a list or map has.
contains(in: text|list|map, value: any) → boolWhether 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) → noneAdd a value to the end of a list.
remove(list: list, value: any) → boolRemove the first matching value. Returns whether one was found.
pop(list: list) → anyRemove and return the last item (none if empty).
sort(list: list, reverse?: bool) → listA sorted copy of a list of numbers or of text.
reverse(list: list) → listA reversed copy of a list.
shuffle(list: list) → listA shuffled copy of a list.
choice(list: list) → anyA random item from a list.
choice(["rock", "paper", "scissors"])range(start: number, end?: number, step?: number) → listNumbers 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) → anyPart of some text or a list, from start up to (not including) end. Negative numbers count from the end.
keys(map: map) → listA map’s keys, as a list.
values(map: map) → listA map’s values, as a list.
get(map: map, key: text, default?: any) → anyA map’s value for a key, or the default if it isn’t there.
Types
type_of(value: any) → textWhat kind of value something is: "number", "text", "list", "user"…
Time
now() → numberThe current time, in seconds since 1970 (a Unix timestamp).
format_time(time: number, style?: text) → textA time that shows in each reader’s own time zone.
time: seconds since 1970style: "relative" (in 2 hours), "date", "time" or "full"
reply("Ends {format_time(now() + 3600)}")wait(seconds: number) → nonePause for a moment (up to 10 seconds in total per run).
wait(2)Errors and debugging
fail(message: text) → noneStop right here and show the message as an error. Can’t be caught by try/except.
fail("You need at least 100 coins.")error(message: text) → noneRaise an error that a try/except around it can catch.
print(values: any, …) → noneWrite a line to the test runner and the run log (not to Discord).
Internet
integrations.weather(place: text) → mapNeeds allow: internetThe 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.
place: a city or place name
w = integrations.weather("London")integrations.define(word: text) → mapNeeds allow: internetAn English dictionary entry: word, phonetic and meanings (a list of maps with part, definition and example). none if it isn’t found.
d = integrations.define("serendipity")integrations.wikipedia(topic: text) → mapNeeds allow: internetA short Wikipedia summary: title, summary, url and image. none if there’s no article.
w = integrations.wikipedia("Octopus")integrations.crypto_price(coin: text, currency?: text) → mapNeeds allow: internetA coin’s price: coin, currency, price and change_24h (percent). none if the coin isn’t found.
coin: e.g. bitcoin, ethereum, solanacurrency: usd (default), eur, gbp…
p = integrations.crypto_price("bitcoin")integrations.steam_game(name: text) → mapNeeds allow: internetA game on Steam: name, price (text), free, url, image and metacritic. none if it isn’t found.
g = integrations.steam_game("Hades")secret(name: text) → secretNeeds allow: internetAn 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.
key = secret("WEATHER_KEY")http.get(url: text, headers?: map, query?: map) → mapNeeds allow: internetFetch a page from a site in your allowlist. Gives a map with status, ok, json (if the answer was JSON) and text. Max only.
url: https, on a site in your allowlist
r = http.get("https://api.example.com/stats", query={"id": "123"})http.post(url: text, json?: any, headers?: map, query?: map) → mapNeeds allow: internetSend JSON to a site in your allowlist. Gives a map with status, ok, json and text, like http.get. Max only.
url: https, on a site in your allowlistjson: sent as JSON (up to 16 KB)
r = http.post("https://api.example.com/scores", json={"user": user.id, "score": 10})