Automations - Variables
Messages sent by Send a message, Reply to the message, Send the member a direct message and Post a log message use templates you save in the Message Builder. Set the member nickname and Create a thread take text with variables too. When a rule runs, these variables are filled in from the event that triggered it and from the rule itself:
| Template | Slug | Variable groups |
|---|---|---|
| Automation action message | @automations.action | Member, Server, Channel, Message, Reaction, Moderation, Levels and anti-raid, Changes, Invite, Role, Rule, Match, Spam |
Member
| Variable | Description |
|---|---|
{user} | Mention of the member behind the event |
{user.mention} | Mention of the member |
{user.name} | Their display name |
{user.display_name} | Their display name |
{user.id} | Their user ID |
{user.tag} | Their tag, for example name or name#1234 |
{user.avatar} | Their avatar URL |
{user.created_at} | When their account was created, as a Discord timestamp (3 years ago) |
{user.joined_at} | When they joined the server, as a Discord timestamp |
{user.roles} | Mentions of their roles, comma separated (empty for a user who left) |
{user.status} | Their online status: online, idle, dnd or offline (needs presences) |
{user.server_tag} | The server tag shown next to their name, if they wear one |
{user.boosting_since} | When they started boosting, as a Discord timestamp (empty when not boosting) |
{author} | Same as {user} |
{author.mention} | Same as {user.mention} |
{author.name} | Their username |
{author.display_name} | Their display name |
{author.id} | Their user ID |
{author.tag} | Their tag |
{author.avatar} | Their avatar URL |
Server
| Variable | Description |
|---|---|
{server} | The server name |
{server.name} | The server name |
{server.id} | The server ID |
{server.member_count} | The member count |
{server.boost_level} | The server's boost level: 0 to 3 |
Channel
| Variable | Description |
|---|---|
{channel} | Mention of the channel where it happened |
{channel.mention} | Mention of the channel |
{channel.name} | The channel name |
{channel.id} | The channel ID |
{channel.type} | The channel's type (text, voice, public_thread, forum...) |
{thread.parent} | Mention of the channel a thread is in (events in a thread) |
{thread.tags} | A forum post's tags, comma separated (thread triggers) |
Message
| Variable | Description |
|---|---|
{message.content} | The text of the message behind the event |
{message.id} | Its ID |
{message.jump_url} | A link to it |
{message.link} | Same as {message.jump_url} |
{message.author} | Mention of who wrote the message (for a reaction: not who reacted) |
{message.author.name} | Their display name |
{message.author.id} | Their user ID |
Reaction
| Variable | Description |
|---|---|
{reaction.emoji} | The emoji added or removed, as it shows in a message (reaction triggers) |
{reaction.name} | The emoji's name: the character, or a server emoji's name |
{reaction.id} | A server emoji's ID (empty for a standard emoji) |
{reaction.url} | A server emoji's image URL (empty for a standard emoji) |
{reaction.count} | How many of this reaction the message has now |
Moderation
| Variable | Description |
|---|---|
{case.number} | The case number (moderation triggers) |
{case_type} | The case type (warn, timeout, ban...) |
{reason} | The case's reason (or the anti-raid level change's) |
{duration} | The timeout or ban length, if any |
{timeout.end} | How a timeout ended: lifted or ran out (timeout ended trigger) |
{mod} | Mention of the moderator (or of who changed the anti-raid level) |
{mod.mention} | Same as {mod} |
{mod.name} | Their username |
{mod.display_name} | Their display name |
{mod.id} | Their user ID |
{mod.tag} | Their tag |
Levels and anti-raid
| Variable | Description |
|---|---|
{level} | The level reached (level-up triggers) |
{level_before} | The level before |
{xp_type} | Which XP: text or voice |
{antiraid.level} | The anti-raid level now (anti-raid trigger) |
Changes
| Variable | Description |
|---|---|
{before.content} | An edited message's text before the edit, when the bot still had it |
{before.nick} | The member's name before (member changes) |
{after.nick} | Their name after |
{changes} | What changed about the member: roles, nickname, boost (member changes) |
{boost} | started or stopped when they started or stopped boosting, else empty |
{roles.added} | Mentions of the roles the member was given (member changes) |
{roles.removed} | Mentions of the roles the member lost |
{status} | Their new custom status (custom status trigger) |
{before.status} | Their custom status before |
{voice.action} | What they did in voice: joined, left, moved, muted, started streaming... |
{before.channel} | The voice channel they were in before (voice trigger) |
{after.channel} | The voice channel they are in now |
{voice.members} | People (not bots) in the voice channel now: the one joined, or the one left |
{voice.duration} | On a leave, how long they were in voice (empty when not known) |
{before.name} | A role's or thread's name before (role and thread updates) |
{after.name} | Its name after |
{before.color} | A role's colour before |
{after.color} | A role's colour after |
{permissions.added} | Permissions a role gained, comma separated |
{permissions.removed} | Permissions a role lost, comma separated |
{before.level} | The anti-raid level before (anti-raid trigger) |
{after.level} | The anti-raid level after |
Invite
| Variable | Description |
|---|---|
{invite.code} | The invite's code (invite created; on a join, the invite they used) |
{invite.url} | The invite link |
{invite.channel} | Mention of the channel it leads to |
{invite.max_uses} | How many uses it allows (unlimited when no limit) |
{invite.max_age} | How long it lasts (never when it does not expire) |
{invite.is_temporary} | Whether it grants temporary membership: yes or no |
{inviter} | Mention of who made the invite a member joined with (member joins) |
{inviter.id} | Their user ID |
{member.rejoined} | Whether the member was in the server before: yes or no (member joins) |
Role
| Variable | Description |
|---|---|
{role} | Mention of the role (role updated trigger) |
{role.mention} | Same as {role} |
{role.name} | The role's name |
{role.id} | The role's ID |
{role.color} | The role's colour |
Rule
| Variable | Description |
|---|---|
{rule.id} | The rule's ID |
{rule.name} | The rule's name |
{rule.description} | The rule's description (empty if not set) |
{trigger.type} | The trigger's internal name, for example on_message |
{trigger.label} | The trigger as the dashboard names it |
{actions.summary} | The rule's actions, comma separated |
Match
| Variable | Description |
|---|---|
{match.summary} | What the conditions (or the spam threshold) matched, on one line |
{match.condition} | The condition that matched first, as the dashboard names it |
{match.value} | What that condition listed that matched (a word, pattern, domain...) |
{match.text} | What was found: the text around a word, a link, a file name |
{match.source} | Where it was found, for example the message or their nickname |
Spam
| Variable | Description |
|---|---|
{spam.count} | How many messages are behind the match (joins or threads for the server-wide triggers) |
{spam.amount} | The threshold's amount |
{spam.window} | The threshold's window in seconds |
{spam.types} | The detectors that matched |
{spam.archive_url} | A link to the archive of the messages behind the match |
Every template also takes the Utility variables.
When each group is filled in:
- Member: the trigger has a member, a message author, or (for a moderation event on someone who already left) a user.
{user.name}is their display name and{author.name}their username. For a reaction, the member is who reacted.{user.created_at}and{user.joined_at}are Discord timestamps, which every reader sees in their own time and language ("3 years ago"). - Server: always.
- Channel: the trigger has a channel or a message.
{thread.parent}is filled when the event happened in a thread. - Message: message and spam triggers, and reactions (the message reacted to).
{message.author}is who wrote it, which for a reaction is usually someone other than{user}. - Reaction: the reaction triggers.
{reaction.emoji}shows the emoji as Discord does;{reaction.id}and{reaction.url}are only set for a server emoji. - Moderation: the moderation triggers.
{mod}and the other moderator variables are empty when nobody acted (a timeout that ran out).{timeout.end}is set on When a member's timeout ends. - Levels and anti-raid:
{level},{level_before}and{xp_type}on the level-up triggers,{antiraid.level}on the anti-raid trigger ({mod}is then the staff member who changed it, and empty when the detector, decay or a rule did). - Changes: what an update changed. A member change fills
{roles.added},{roles.removed},{before.nick}and{after.nick}; a custom status{status}and{before.status}; a voice change{voice.action},{before.channel}and{after.channel}; a role update the names, colours and permissions before and after; a thread update{before.name}and{after.name}(when the bot still had the thread's old version); the anti-raid trigger{before.level}and{after.level}; an edited message{before.content}(when the bot still had the message). - Invite: When an invite is created.
- Role: When a role is updated: the role as it is now.
- Rule: always.
{actions.summary}lists the rule's actions, whether or not each one succeeds. - Match:
{match.summary}says what the conditions matched (the words, patterns, links, invites and file types of the conditions that made the rule pass, and where they were found) or, on a spam trigger, the spam match, for examplemessage spam: 6 events (threshold 5 in 10s). The other match variables describe the first condition that matched. They are empty when no content, link, invite, file or name condition matched. - Spam: spam triggers.
{spam.count}is how many messages are behind the match (for a join raid or thread spam: how many members joined or threads were created),{spam.archive_url}a link to the archive of those messages (a web page kept for 30 days; empty for join raids and thread spam, or without the Mod Logs module). On Any spam detected, which can match several detectors at once,{spam.amount}and{spam.window}are those of the first detector that matched.
Which trigger fills what
| Trigger | Variables it fills |
|---|---|
| When a message is sent | Member; Server; Channel; Message; Changes ({before.content}); Rule; Match |
| When a member joins | Member; Server; Invite ({invite.code}, {inviter}, {inviter.id}, {member.rejoined}); Rule; Match |
| When a member leaves | Member; Server; Rule; Match |
| When a reaction is added | Member; Server; Channel; Message; Reaction; Rule; Match |
| When a reaction is removed | Member; Server; Channel; Message; Reaction; Rule; Match |
| When a member changes (roles, nickname or boosting) | Member; Server; Changes ({before.nick}, {after.nick}, {changes}, {boost}, {roles.added}, {roles.removed}); Rule; Match |
| When a voice state changes (join, leave, move, mute) | Member; Server; Channel ({channel}, {channel.mention}, {channel.name}, {channel.id}, {channel.type}); Changes ({voice.action}, {before.channel}, {after.channel}, {voice.members}, {voice.duration}); Rule; Match |
| When a thread is created | Member; Server; Channel; Rule; Match |
| When a thread is deleted | Member; Server; Channel; Rule; Match |
| When a thread is updated | Member; Server; Channel; Changes ({before.name}, {after.name}); Rule; Match |
| When a thread is archived | Member; Server; Channel; Rule; Match |
| When a thread is unarchived | Member; Server; Channel; Rule; Match |
| On a time schedule (cron-like) | Server; Rule |
| When an invite is created | Member; Server; Channel ({channel}, {channel.mention}, {channel.name}, {channel.id}, {channel.type}); Invite ({invite.code}, {invite.url}, {invite.channel}, {invite.max_uses}, {invite.max_age}, {invite.is_temporary}); Rule; Match |
| When a channel is created | Server; Channel ({channel}, {channel.mention}, {channel.name}, {channel.id}, {channel.type}); Rule; Match |
| When a role is updated | Server; Changes ({before.name}, {after.name}, {before.color}, {after.color}, {permissions.added}, {permissions.removed}); Role; Rule; Match |
| When a member changes their custom status | Member; Server; Changes ({status}, {before.status}); Rule; Match |
| When a member is warned | Member; Server; Moderation ({case.number}, {case_type}, {reason}, {mod}, {mod.mention}, {mod.name}, {mod.display_name}, {mod.id}, {mod.tag}); Rule; Match |
| When a member is timed out | Member; Server; Moderation ({case.number}, {case_type}, {reason}, {duration}, {mod}, {mod.mention}, {mod.name}, {mod.display_name}, {mod.id}, {mod.tag}); Rule; Match |
| When a member is kicked | Member; Server; Moderation ({case.number}, {case_type}, {reason}, {mod}, {mod.mention}, {mod.name}, {mod.display_name}, {mod.id}, {mod.tag}); Rule; Match |
| When a member is banned | Member; Server; Moderation ({case.number}, {case_type}, {reason}, {duration}, {mod}, {mod.mention}, {mod.name}, {mod.display_name}, {mod.id}, {mod.tag}); Rule; Match |
| When a member is unbanned | Member; Server; Moderation ({case.number}, {case_type}, {reason}, {mod}, {mod.mention}, {mod.name}, {mod.display_name}, {mod.id}, {mod.tag}); Rule; Match |
| When a member's timeout ends | Member; Server; Moderation ({case.number}, {case_type}, {reason}, {timeout.end}, {mod}, {mod.mention}, {mod.name}, {mod.display_name}, {mod.id}, {mod.tag}); Rule; Match |
| When a note is added to a member | Member; Server; Moderation ({case.number}, {case_type}, {reason}, {mod}, {mod.mention}, {mod.name}, {mod.display_name}, {mod.id}, {mod.tag}); Rule; Match |
| Any spam detected | Member; Server; Channel; Message; Rule; Match; Spam |
| Message spam detected | Member; Server; Channel; Message; Rule; Match; Spam |
| Mention spam detected | Member; Server; Channel; Message; Rule; Match; Spam |
| Link spam detected | Member; Server; Channel; Message; Rule; Match; Spam |
| Attachment spam detected | Member; Server; Channel; Message; Rule; Match; Spam |
| Emoji spam detected | Member; Server; Channel; Message; Rule; Match; Spam |
| Line spam detected | Member; Server; Channel; Message; Rule; Match; Spam |
| Character spam detected | Member; Server; Channel; Message; Rule; Match; Spam |
| Sticker spam detected | Member; Server; Channel; Message; Rule; Match; Spam |
| Join raid detected | Member; Server; Rule; Match; Spam |
| Thread creation spam detected | Member; Server; Channel; Rule; Match; Spam |
| When anti-raid level changes | Server; Moderation ({reason}, {mod}, {mod.mention}, {mod.name}, {mod.display_name}, {mod.id}, {mod.tag}); Levels and anti-raid ({antiraid.level}); Changes ({before.level}, {after.level}); Rule; Match |
| When a member levels up via text XP | Member; Server; Levels and anti-raid ({level}, {level_before}, {xp_type}); Rule; Match |
| When a member levels up via voice XP | Member; Server; Levels and anti-raid ({level}, {level_before}, {xp_type}); Rule; Match |
Variables that do not apply to an event are not filled in; for example a scheduled rule has no {user} or {channel}, so avoid them in scheduled messages. Some of these can still be empty on a trigger that fills them, as the notes above say: {voice.duration} for someone who joined voice before the bot started, {mod} when nobody acted. {match.summary} is written for Discord: formatting characters and mentions in the matched text are escaped. {match.value} and {match.text} are the plain text.
The Message Builder lists these variables for a template whose ID starts with automations.action, for example automations.action.invite-warning. Create template on an action gives the new template such an ID. Any template works with an action; the ID only decides what the variable list shows. Opened from a rule (Create template or Edit on one of its actions), the builder lists only the variables the rule's trigger fills, and so do the variable suggestions in an action's own text fields (a nickname, a thread name); Show all in the builder lists the rest, for a template several rules share.
In message templates, filters work as everywhere else, for example {message.content | truncate(100)} or {user.display_name | upper}. Nicknames and thread names take the plain variables only, without filters. See the Message Builder guide for the filters and the Utility variables every template has.