Connect
Establishes a connection to Discord using a bot token and returns a client ID for use in subsequent Discord operations.
Common Properties
- Name - The custom name of the node.
- Color - The custom color of the node.
- Delay Before (sec) - Waits in seconds before executing the node.
- Delay After (sec) - Waits in seconds after executing node.
- Continue On Error - Automation will continue regardless of any error. The default value is false.
If the ContinueOnError property is true, no error is caught when the project is executed, even if a Catch node is used.
Options
- Bot Token - The Discord bot authentication token credential. This is obtained from the Discord Developer Portal when you create a bot application.
Output
- Client Id - A unique identifier for the bot session that must be used in subsequent Discord operations. This ID references the active bot connection.
How It Works
The Connect node is the first step in many Discord automation flows. It creates a Discord bot session and stores it for reuse by other nodes.
When executed, the node:
- Retrieves the bot token from the provided credentials
- Creates a new Discord bot session using the token
- Stores the bot session in a thread-safe session manager
- Returns a unique Client ID that references this session
- This Client ID is then used by other Discord nodes to access the bot
Requirements
- A Discord application with a bot user
- A valid Discord bot token
- The bot token must be stored as a credential in Robomotion
- Appropriate bot permissions configured in the Discord Developer Portal
Error Handling
The node will return specific errors in the following cases:
- ErrInvalidArg - Invalid or missing bot token credential
- ErrInvalidArg - Empty bot token value in the credential
- Discord API connection errors
Usage Notes
- The Connect node should be executed before other Discord operations
- The returned Client ID must be passed to subsequent Discord nodes
- Each Connect node creates a new session entry
- Use the Disconnect node to clean up the session when it's no longer needed
- The bot session is stored in memory and automatically removed when the flow stops
Alternative Authentication
Many Discord nodes support direct token authentication without using Connect. You can provide the bot token directly in each node's credentials instead of using the Client ID method. This is useful for simple, one-off operations.
Best Practices
- Store your Discord bot token as a credential rather than hardcoding it
- Use a single Connect node at the beginning of your flow
- Always pair Connect with Disconnect nodes to properly clean up resources
- Handle errors appropriately to prevent credential exposure
- Keep your bot token secret and never share it
Example Flow
Simple message sending flow:
- Connect node - Authenticate with Discord
- Store the
client_idoutput - Send Channel Message node - Use the
client_idto send messages - Disconnect node - Clean up the session
Getting Your Bot Token
- Visit the Discord Developer Portal
- Select your application (or create a new one)
- Navigate to the "Bot" section in the left sidebar
- Under "Token", click "Copy" to copy your bot token
- Store this token securely in Robomotion's Vault
Never share your bot token publicly or commit it to version control. Treat it like a password. If your token is exposed, regenerate it immediately in the Discord Developer Portal.