Creating a Bot

Step 1. Create an application (follow the link).

Step 2. Add a bot (click on the "Add Bot" button).

Step 2.1. In the Installation section, select Install Link → None.

Step 2.2. In the Bot section, disable Public Bot, then enable the following Intents:

  • Message Content Intent
  • Server Members Intent

You may also enable Presence Intent for future use.

Step 3. Get the token (Reset Token).

Step 4. Add the bot to the server:

  • Go to OAuth2 → URL Generator.
  • In Scopes, select bot.
  • In Bot Permissions, choose Send Messages, Read Message History, and any other required permissions.

Then open the generated link, select the server where you want to add the bot, and confirm the authorization.

To obtain the full webhook from Discord, simply assign any value to the save_webhook variable.

If the variable is set, the webhook will be saved to discord_webhook.

Connecting the Discord Bot in MaviBot

Now go to the “Messengers” section in your project in MaviBot:

Then paste the token copied from Discord.

Click the Done button.

Calculator Functions

Reply to a Message

discord_reply_to_message(message_id, text) - This function is used to reply to a message.

Parameters Description
! message_id The ID of the message to which you want to reply.
! text The text of the reply message.

Delete a Message

discord_delete_message(message_id) - This function is used to delete a message.

Parameters Description
! message_id The ID of the message to delete.

Edit a Message

discord_edit_message(message_id, text) - This function is used to edit a message.

Parameters Description
! message_id The ID of the message to edit.
! text The new text of the message.

Pin a Message

discord_pin_message(message_id) - This function is used to pin a message.

Parameters Description
! message_id The ID of the message to pin.

Unpin a message

discord_unpin_message(message_id) - This function is used to unpin a message.

Parameters Description
! message_id The ID of the message to unpin.

Send a reaction to a message

discord_send_reaction(message_id, reaction) - This function is used to send a reaction to a message.

Parameters Description
! message_id The ID of the message to send a reaction to.
! reaction The reaction to send. You can provide a single emoji (e.g., ❤️) or the ID of a custom emoji on the server. Information on how to get the ID of a custom emoji is provided below.

Remove a reaction from a message in a channel

discord_delete_reaction(message_id, reaction, user_id) - This function is used to remove a reaction from a message in a channel.

Parameters Description
! message_id The ID of the message from which to remove the reaction.
! reaction The reaction to remove. You can provide a single emoji (e.g., ❤️) or the ID of a custom emoji on the server. Information on how to get the ID of a custom emoji is provided below.
user_id The ID of the user whose reaction you want to remove. This parameter is optional if you want to remove the reaction from the current bot.

Discord Functions

The following functions allow you to manage Discord servers, members, channels, roles, messages, and invites.

Member Moderation

Ban a Member

discord_ban_member(user_id, delete_message_seconds) - This function is used to ban a member from the Discord server.

Parameters Description
! user_id The Discord user ID of the member to ban.
delete_message_seconds (Optional) Deletes the member's previous messages from the specified number of seconds before the ban. Set 0 to keep all messages.

Unban a Member

discord_unban_member(user_id) - This function is used to remove a ban from a member.

Parameters Description
! user_id The Discord user ID of the member to unban.

Kick a Member

discord_kick_member(user_id) - This function is used to remove a member from the server without banning them.

Parameters Description
! user_id The Discord user ID of the member to remove.

A kicked member can join the server again using a valid invite link.

Timeout a Member

discord_timeout_member(user_id, seconds) - This function is used to place a member in timeout (mute).

Parameters Description
! user_id The Discord user ID of the member.
! seconds Timeout duration in seconds.

Remove Timeout

discord_remove_timeout(user_id) - This function is used to remove a member's timeout before it expires.

Parameters Description
! user_id The Discord user ID of the member.

Bulk Delete Messages

discord_bulk_delete_messages(channel_id, message_ids) - This function is used to delete multiple messages from a channel.

Parameters Description
! channel_id The Discord channel ID.
! message_ids A list of message IDs to delete.

Messages

Send a Message

discord_send_message(channel_id, text) - This function is used to send a message to a Discord channel.

Parameters Description
! channel_id The Discord channel ID.
! text The message text.

Get a Message

discord_get_message(channel_id, message_id) - This function is used to retrieve information about a message.

Parameters Description
! channel_id The Discord channel ID.
! message_id The ID of the message.

The function returns:

  • Message content
  • Author information
  • Attachments

Send a Direct Message

discord_send_dm(user_id, text) - This function is used to send a direct message to a server member.

Parameters Description
! user_id The Discord user ID.
! text The message text.

Roles

Add a Role

discord_add_role(user_id, role_id) - This function is used to assign a role to a member.

Parameters Description
! user_id The Discord user ID.
! role_id The Discord role ID.

Remove a Role

discord_remove_role(user_id, role_id) - This function is used to remove a role from a member.

Parameters Description
! user_id The Discord user ID.
! role_id The Discord role ID.

Change Member Nickname

discord_set_nickname(user_id, nickname) - This function is used to change a member's nickname on the server.

Parameters Description
! user_id The Discord user ID.
! nickname The new nickname.

Get Server Roles

discord_get_roles() - This function is used to retrieve the list of server roles.

The function returns:

  • Role ID
  • Role name

Members

Get Member Information

discord_get_member(user_id) - This function is used to retrieve information about a server member.

Parameters Description
! user_id The Discord user ID.

The function returns:

  • Member roles
  • Server nickname
  • Join date
  • Permissions

Channels

Create a Channel

discord_create_channel(name, type, parent_id, permission_overwrites) - This function is used to create a new Discord channel.

Parameters Description
! name The channel name.
! type The channel type (for example, text or voice).
parent_id The category ID where the channel will be created.
permission_overwrites Channel permission settings that define which users or roles can access the channel.

Delete a Channel

discord_delete_channel(channel_id) - This function is used to delete a Discord channel.

Parameters Description
! channel_id The Discord channel ID.

Set Channel Permissions

discord_set_channel_permission(channel_id, target_id, allow, deny) - This function is used to configure channel permissions for a user or role.

Parameters Description
! channel_id The Discord channel ID.
! target_id The user ID or role ID whose permissions will be changed.
! allow Permissions to grant.
! deny Permissions to deny.

Invites

Create an Invite

discord_create_invite(channel_id, max_age, max_uses) - This function is used to create an invite link.

Parameters Description
! channel_id The Discord channel ID.
max_age Invite lifetime in seconds. Use 0 for no expiration.
max_uses Maximum number of uses. Use 0 for unlimited uses.

Get Server Invites

discord_get_invites() - This function is used to retrieve all server invite links.

The function returns:

  • Invite URL
  • Number of uses
  • Remaining lifetime (if applicable)

Webhook Events

The following Discord events can be forwarded to the chat flow:

  • Member joined the server
  • Member left the server
  • Member was kicked
  • Member was banned
  • Member was unbanned
  • Member roles changed
  • Message edited
  • Message deleted
  • Reaction added
  • Reaction removed
  • Slash command executed
  • Button clicked

Webhook Payload

Webhook data is available in:

discord_webhook["data"]
Field Description
author_id Discord user ID of the message author.
username Discord username.
nickname Server nickname.
channel_id Discord channel ID.
guild_id Discord server ID.
message_id Discord message ID.
content Message text.
roles List of the member's role IDs.
is_admin Indicates whether the member has administrator privileges.

Callbacks

When a user sends a reaction, a callback is received in the chat in the following format:

new_like ❤️ uid413984787162726410

Where uid413984787162726410 is the ID of the user who sent the reaction.

How to get the ID of a custom emoji

If you send a custom reaction to a message in a Discord channel, a callback will be received in the following format:

new_like beer:1479419477396291696 uid413984787162726410

Where beer:1479419477396291696 is the ID of the reaction. You can copy it for use in reaction-related functions.

How to get the Message ID

You can get the client’s message ID from the webhook if save_webhook is enabled. Example:

data = discord_webhook["data"]
msg_id = data["id"]
result = discord_reply_to_message(msg_id, "This is a reply to a message")

Additional Callbacks

In addition to new_like, the following callbacks are available:

Callback Description
new_like {emoji} uid{user_id} A user added a reaction to a message.
reaction_remove {emoji} uid{user_id} A user removed a reaction from a message.
message_delete mid{message_id} A message was deleted.
message_edit mid{message_id} A message was edited. The updated message text is available in the webhook data.
member_join uid{user_id} A member joined the server.
member_leave uid{user_id} A member left the server.
member_update uid{user_id} A member's information (such as roles or nickname) was updated.
member_ban uid{user_id} A member was banned from the server.
member_unban uid{user_id} A member was unbanned from the server.

Callback Variables

For consistency with the existing Discord event format, user and message identifiers use historical prefixes:

  • User IDs are returned as uid{user_id}.
  • Message IDs are returned as mid{message_id}.

The following variables also use these prefixed identifiers:

  • message_from
  • internal_id
  • discord_webhook["data"]