Discord
The Discord handler in Bot Studio is responsible for managing Discord bots. This handler leverages the Discord Bolt library and uses the official Discord API to handle bot functionalities.
Verifications
The origin server sends verification requests to the Discord handler to validate the provided Discord application tokens.
Activating Bots
When activating a Discord bot instance, Bot Studio first determines the required intents for the bot based on the events it will listen to. For example, if the bot uses the Webhooks Update Event
, the GUILD_WEBHOOKS
intent will be activated. A list of all gateway intents can be found here.
Next, Bot Studio creates a Discord client with the required intents, which listens to events the bot uses, such as the Message Create Event
. An API client is also created for the bot to send API requests to the Discord API.
Receiving Events
When an event is received, the executor will be identified based on the type of event. The variables created from the event include:
client
: The created client instance.- Event-specific variables: For instance, when a
Message Create
event is received, this payload is received, and its variables are included in the list based on the information provided here. A list of all event payloads can be found here.
Executing Worker Nodes
Node names in Bot Studio are not opinionated. Each name references a specific feature. Node names in Discord bots are not opinionated and include the name of the category to which the node belongs and the endpoint it uses. For example:
- Create Message: This node belongs to the channel category and uses the create message endpoint.
An API request is sent to the target Discord API endpoint to execute the node function. The request body is the same as the node data.
Advertisements
Advertisements are only shown if the bot is not upgraded to remove ads.
After sending API requests with worker nodes, the handler checks if the node has a valid channel ID where an advertisement message can be sent. There is a 1 in 8 random chance of showing an advertisement. If all conditions are met, an advertisement message is sent to the channel.
Advertisements are designed to be non-intrusive.