How to make a Discord bot

Creating a Bot

Step 1. Create an application (follow the linkarrow-up-right).

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.

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")

Last updated