Messages, members and roles
These functions talk to Discord. Each run can make a limited number of Discord actions (see limits).
Messages
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}")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)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")permissions: setting.Server and channels
Scripts can make, change and delete channels and roles, lock channels, start threads and change server settings, with allow: server. As with roles, the person running the command needs the matching permission (like Manage Channels), and new roles never get permissions: give those in Discord.
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"
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)