Overview
This node acts as a trigger for Discord events, specifically listening for new messages in selected channels. It is designed to integrate with a Discord bot via IPC (Inter-Process Communication) to receive real-time message events. When a message is sent in the configured channels, the node emits data about that message, allowing workflows to react immediately.
Common scenarios include:
- Automating responses or actions based on specific messages in Discord channels.
- Logging or processing messages from Discord in external systems.
- Triggering workflows when users send commands or keywords in Discord.
Example: A workflow could be triggered whenever a user sends a message containing a certain keyword in a Discord channel, which then processes the message content or sends a notification elsewhere.
Properties
| Name | Meaning |
|---|---|
| Trigger Type | Type of event to listen to. Currently supports only "Message" — triggers when a message is sent in channels. |
Output
The node outputs JSON data representing the Discord message event. The structure includes:
id: The unique identifier of the message.content: The text content of the message.channelId: The ID of the channel where the message was sent.authorId: The ID of the user who sent the message.authorName: The username of the message author.timestamp: The timestamp when the message was created.guild: The ID of the guild (server) where the message was sent, if applicable.listenValue: The value of the "value" parameter from the node's configuration (usage context not fully detailed).
The node does not output binary data.
Dependencies
- Requires a Discord bot API token credential to connect and authenticate with Discord.
- Uses an IPC mechanism to communicate with a separate bot process.
- Relies on helper functions to fetch channels and roles, and to manage connections.
- Needs proper configuration of the Discord bot and its permissions to listen to messages in specified channels.
Troubleshooting
- No token given: If the API token credential is missing or invalid, the node will log "No token given." and will not function. Ensure the Discord bot token is correctly set up in credentials.
- Disconnected from IPC server: Indicates loss of connection to the bot process. Check that the bot process is running and accessible.
- Workflow stopped: When the workflow stops or the node is deactivated, it attempts to disconnect the bot. If this does not happen cleanly, residual connections may persist.
- Permission issues: The Discord bot must have permission to read messages in the target channels; otherwise, no events will be received.
- Channel or role fetching errors: Errors during loading options for channels or roles are caught but should be investigated if they prevent proper configuration.
Links and References
- Discord Developer Portal
- n8n Documentation - Creating Custom Nodes
- Node.js IPC Documentation (for understanding inter-process communication)