Functions can be called in a block's Variables field or directly in the response text using #{...}:
#{discord_add_role(message_from, '1465674567090704592')}
Discord server, channel, role, and message IDs are long numeric values. The easiest way to copy them is to enable Settings → Advanced → Developer Mode. After that, the Copy ID option will appear in the context menu of any object.
Bot connection is described in the How to Create a Chatbot in Discord article.
Where to Get the Message ID
The ID of the message that triggered the block is stored in the discord_message_id variable. You do not need to retrieve it separately:
#{discord_delete_message(discord_message_id)}
If you need data that is not available in the predefined variables, the full webhook is available in the discord_webhook variable. It is populated when any value is assigned to the save_webhook variable:
data = discord_webhook["data"]
msg_id = data["id"]
result = discord_reply_to_message(msg_id, "This is a reply to the message")
Variables Created Automatically
These variables are populated automatically for each event and do not require any additional configuration.
| Variable | Description | Example |
|---|---|---|
guild_id |
Server ID | 1465674567090704591 |
discord_event |
Event type as a single word | message |
discord_message_id |
Message ID with the mid prefix |
mid1465674569095319625 |
message_from |
Event author's ID with the uid prefix |
uid413984787162726410 |
from_username |
Author's Discord username | 00rei |
from_name |
Author's display name in the chat | Rus |
username |
Username for direct messages to the bot | 00rei |
is_bot |
1 if the event author is another bot |
0 |
nickname |
Server nickname; empty if not set | Moderator |
roles |
List of the author's role IDs | ["1465674567090704592"] |
is_admin |
1 if the user is an administrator or server owner |
1 |
reply_from |
ID of the author of the message being replied to | uid493121376652230668 |
reply_from_username |
Username of the author being replied to | _deikin |
reply_from_name |
Display name of the author being replied to | Rus |
reply_to_bot |
1 if the reply is to the bot |
0 |
reply_message_id |
ID of the message being replied to | mid1534837349219958804 |
reply_text |
Text of the message being replied to | who is on duty today? |
The uid, cid, and mid prefixes are part of the value. Pass these variables to functions as they are; you do not need to remove the prefixes.
from_name vs. from_username
from_name contains the name that should be used to address the user in the chat:
- Server nickname, if set.
- Account display name.
- Username.
This is the recommended variable to use in greetings because from_username may look like _deikin or 00rei.
The reply_* variables are populated only when the incoming message is a reply to another message. For regular messages, all of them are cleared.
Therefore, the following condition reliably distinguishes a reply from a regular message:
#{reply_from != ''}
The nickname, roles, and is_admin variables refer to the author of the current event.
Discord does not provide this data for reaction events, so administrator checks should be performed on a message or slash command event.
The incoming message text is stored in the standard question variable, just like in other channels.
Events
In addition to regular messages, service events are also sent to the funnel.
Their text is stored in the question variable, so you can handle them using regular text conditions.
discord_event |
Text in question
|
When It Occurs |
|---|---|---|
message |
Message text | A member sends a message |
message_edit |
Updated message text | A message is edited |
interaction |
/warn @user spam |
A slash command is used or a button is clicked |
reaction_add |
new_like ❤️ uid413984787162726410 |
A reaction is added |
reaction_remove |
reaction_remove ❤️ uid413984787162726410 |
A reaction is removed |
message_delete |
message_delete mid1465674569095319625 |
A message is deleted |
messages_delete_bulk |
messages_delete_bulk 12 |
Multiple messages are deleted |
member_join |
member_join uid413984787162726410 |
A member joins the server |
member_leave |
member_leave uid413984787162726410 |
A member leaves the server |
member_update |
member_update uid413984787162726410 |
A member's nickname or roles change |
member_ban |
member_ban uid413984787162726410 |
A member is banned |
member_unban |
member_unban uid413984787162726410 |
A member is unbanned |
For a custom reaction, the custom emoji ID is used instead of the emoji itself:
new_like beer:1479419477396291696 uid413984787162726410
See the Reactions section for details.
If a block should trigger only for regular messages sent by members, add the following condition:
discord_event == 'message'
This filters out all service events at once.
Checking only the event text is unreliable because a member could manually send a message such as member_join.
Important:
member_updateis triggered by any member update, including a role assigned by the bot itself. A block that reacts tomember_updateand assigns a role can create a loop, so such conditions should always be restricted appropriately.
Messages
| Function | Description |
|---|---|
discord_send_message(channel_id, text) |
Send a message to any channel |
discord_send_dm(user_id, text) |
Send a direct message to a member |
discord_reply_to_message(message_id, text) |
Reply to a message |
discord_edit_message(message_id, text) |
Edit a message sent by the bot |
discord_delete_message(message_id) |
Delete a message |
discord_bulk_delete_messages(channel_id, message_ids) |
Delete multiple messages at once |
discord_get_message(channel_id, message_id) |
Retrieve a message |
discord_pin_message(message_id) |
Pin a message |
discord_unpin_message(message_id) |
Unpin a message |
Discord limitations: There is no time limit for editing or deleting your own messages. Bulk deletion works only for messages less than 14 days old, and you can delete between 2 and 100 messages at a time.
Reactions
| Function | Description |
|---|---|
discord_send_reaction(message_id, reaction) |
Add a reaction |
discord_delete_reaction(message_id, reaction, user_id) |
Remove a reaction. If user_id is omitted, the bot's reaction is removed |
The reaction parameter accepts either a regular emoji, such as ❤️, or the ID of a custom server emoji.
Where to Get a Custom Reaction ID
Add the required custom reaction to any message in the channel.
A callback like this will appear in the chat:
new_like beer:1479419477396291696 uid413984787162726410
Here:
beer:1479419477396291696
is the reaction ID.
You can copy it and use it in reaction functions:
#{discord_send_reaction(discord_message_id, 'beer:1479419477396291696')}
Regular emojis appear in callbacks as they are:
new_like ❤️ uid413984787162726410
where uid413984787162726410 is the ID of the member who added the reaction.
Moderation
| Function | Description |
|---|---|
discord_timeout_member(user_id, seconds) |
Timeout a member for the specified number of seconds, up to 28 days |
discord_remove_timeout(user_id) |
Remove a timeout early |
discord_kick_member(user_id) |
Kick a member from the server; they can return using an invite |
discord_ban_member(user_id, delete_message_seconds) |
Ban a member; the second argument specifies how many seconds of message history to delete, up to 7 days |
discord_unban_member(user_id) |
Unban a member |
Discord does not allow the bot to moderate a member whose role is higher than the bot's role. The server owner cannot be moderated either.
Roles and Members
| Function | Description |
|---|---|
discord_add_role(user_id, role_id) |
Assign a role |
discord_remove_role(user_id, role_id) |
Remove a role |
discord_get_roles() |
Get the server's roles and their IDs |
discord_get_member(user_id) |
Get member data, including nickname, roles, and join date |
discord_set_nickname(user_id, nickname) |
Change a member's server nickname |
The bot's role must be higher than the role it is assigning.
The @everyone role and roles managed by integrations, including roles belonging to other bots, cannot be assigned.
Channels and Tickets
| Function | Description |
|---|---|
discord_create_channel(name, type, parent_id, permission_overwrites) |
Create a channel |
discord_delete_channel(channel_id) |
Delete a channel |
discord_set_channel_permission(channel_id, target_id, allow, deny, type) |
Allow or deny channel permissions |
discord_create_invite(channel_id, max_age, max_uses) |
Create an invite link |
discord_get_invites() |
Get the server's invite links |
For discord_create_channel, the default type is:
| Value | Channel Type |
|---|---|
0 |
Text channel |
2 |
Voice channel |
4 |
Category |
You can pass a category ID in parent_id to create the channel inside that category.
For discord_set_channel_permission, the last argument specifies who receives the permissions:
| Value | Target |
|---|---|
1 |
Member |
0 |
Role |
The allow and deny parameters accept the following values:
| Value | Permission |
|---|---|
1024 |
View channel |
2048 |
Send messages |
3072 |
View channel and send messages |
65536 |
Read message history |
For discord_create_invite, the invite lifetime is specified in seconds.
For example:
86400
means 24 hours.
A max_uses value of 0 means unlimited uses.
Slash Commands
| Function | Description |
|---|---|
discord_get_commands() |
Get the commands registered on the server |
discord_set_commands(commands) |
Replace the entire set of commands |
discord_set_commands accepts a list of commands:
#{discord_set_commands('[
{
"name": "rules",
"description": "Show server rules"
},
{
"name": "warn",
"description": "Issue a warning",
"options": [
{
"type": 6,
"name": "user",
"description": "User",
"required": true
},
{
"type": 3,
"name": "reason",
"description": "Reason",
"required": false
}
]
}
]')}
Discord Requirements
-
namemust contain lowercase characters only, without spaces, and must be between 1 and 32 characters long. -
descriptionis required and must be between 1 and 100 characters long. - Required options must appear before optional options.
- Passing an empty list removes all bot commands from the server.
Option Types
| Type | Description |
|---|---|
3 |
String |
4 |
Integer |
5 |
Boolean |
6 |
Member |
7 |
Channel |
8 |
Role |
When a command is called, it is sent to the funnel as a string such as:
/warn @user spam
In other words, the command name and option values are separated by spaces.
You can handle it using a regular text condition.
A separate function for buttons is not required. Buttons are configured in a regular response block, and a button click is received in the same way as a slash command: the button value appears in the text.
Points and Leaderboard
Discord integration includes a built-in appreciation system. Points are awarded to the author of the quoted message.
You can use it to build levels, ranks, and leaderboards.
| Function | Description |
|---|---|
discord_add_thanks_score(value) |
Add points to the author of the quoted message |
discord_add_thanks_score_for_answer(value) |
Add points to the member who replied |
discord_minus_thanks_score(value) |
Remove points |
discord_get_score(user_id) |
Return a member's points as a number. Without an argument, uses the event author |
discord_get_level(user_id, points_per_level) |
Get a member's level. Default threshold: 100 points per level |
discord_get_user_info(user_id) |
Get points, leaderboard position, and name as a single object |
discord_get_top(count, shift, humanize, delimiter) |
Get the leaderboard |
For discord_get_top:
-
count— number of rows to return; -
shift— number of rows to skip, useful for pagination; -
humanize=true— returns ready-to-display text; -
delimiter— separator between the member's name and points.
When comparing points in a block condition, use discord_get_score. This function returns a number, so numeric comparisons work as expected.
Examples
Welcome a New Member via Direct Message
Block condition:
member_join
In the Variables field:
discord_send_dm(
message_from,
'Hi, #{from_name}! Check out the pinned rules.'
)
Delete a Message Containing a Stop Word and Timeout the Member for 24 Hours
Block condition: a list of stop words.
Additional condition:
is_admin != 1
Functions:
discord_delete_message(discord_message_id)
discord_timeout_member(message_from, 86400)
Assign a Role for a Reaction to a Specific Message
Block condition:
new_like 🍕
Additional condition:
contains(discord_message_id, '1534927170965602324')
Function:
discord_add_role(
message_from,
'1465674567090704592'
)
Create a Private Ticket Channel from a Button
ticket = discord_create_channel(
'ticket-' + from_username
)
ticket_channel = get(
get(ticket, 'data'),
'id'
)
discord_set_channel_permission(
ticket_channel,
guild_id,
None,
1024,
0
)
discord_set_channel_permission(
ticket_channel,
message_from,
3072,
None,
1
)
discord_send_message(
ticket_channel,
'Describe your issue in a single message.'
)
The first permission line hides the channel from everyone (guild_id represents the @everyone role here).
The second line makes the channel available to the member who created the ticket.
Award Points for Thanks and Assign a Role Based on Level
Block condition:
thanks;thx;thank you
Additional condition:
reply_from != '' and reply_from != message_from and reply_to_bot != 1
Functions:
discord_add_thanks_score(1)
if (discord_get_level(reply_from) >= 1) {
discord_add_role(
reply_from,
'1465674567090704592'
)
}
The condition:
reply_from != message_from
prevents members from awarding points to themselves.
The condition:
reply_to_bot != 1
prevents points from being awarded to the bot.
Show Your Points with a Command
Block condition:
/xp
In the Variables field:
points = discord_get_score()
lvl = discord_get_level()
Response text:
#{from_name}, you have #{points} XP · Level #{lvl}
Show the Leaderboard with a Command
Block condition:
/top
Response text:
🏆 XP Leaderboard:
#{discord_get_top(10, 0, true, ' — ')}