Discord Trigger icon

Discord Trigger

Discord Trigger on message

Overview

This node acts as a trigger for various Discord events, enabling workflows to start based on specific activities within Discord servers. It listens for events such as messages, direct messages, reactions added or removed, role changes, and user join/leave/update events. This is useful for automating responses, logging activities, moderating content, or integrating Discord interactions with other systems.

Practical examples include:

  • Triggering a workflow when a user sends a message containing a specific command.
  • Starting an automation when a new user joins a server.
  • Reacting to role changes by updating external databases.
  • Monitoring message reactions to tally votes or feedback.

Properties

Name Meaning
Trigger Type The type of Discord event to listen for. Options include: Direct Message, Message in channels, Reaction Add/Remove, Role Add/Delete/Update, User Join/Leave/Update.
Server Names or IDs Select one or more Discord servers (guilds) to listen to. Only applicable for certain event types like messages, reactions, roles, and user events.
Listen To Channels Select specific text channels within the chosen servers to listen for messages or reactions. If none selected, all channels are monitored.
Listen to Roles Optionally restrict listening to messages or reactions from users with specific roles. If none selected, listens to everyone (@everyone).
Listen to Message For reaction add/remove events, specify a particular message ID to limit triggering only to reactions on that message.
Pattern Defines how to match message content for message or direct message triggers. Options include Bot Mention, Contains, Ends With, Equals, Every message, Regex, Starts With.
Value The string or regex pattern used to match against messages, depending on the selected pattern. Required for message and direct message triggers except when pattern is "Every".
Case Sensitive Whether the message matching should be case sensitive.
Trigger Only on Message Replies If enabled, the trigger activates only when the message is a reply to another message. The replied-to message details are included in the output.
Message ID For interaction triggers (e.g., button/select), specifies the message ID to listen to.
Additional Fields Collection of optional settings:
• Trigger on Other Bot Input — whether to trigger on messages sent by other bots.
• Attachment(s) Required — require at least one attachment in the message to trigger.

Output

The node outputs JSON data representing the event details corresponding to the triggered Discord event:

  • Message Events: Includes message ID, content, guild ID, channel ID, author ID and name, timestamp, attachments if any, and optionally referenced message details if the message is a reply.
  • User Events (Join, Leave, Update): Outputs the user or guild member object with relevant properties.
  • Role Events (Create, Delete, Update): Outputs role objects; for updates, includes old and new role data with prefixed keys.
  • Reaction Events (Add, Remove): Outputs combined reaction and user data along with channel and guild IDs.
  • Interaction Events: Outputs data related to the interaction message specified.

If binary data were involved (not indicated here), it would typically represent attachments or media, but this node primarily outputs structured JSON event data.

Dependencies

  • Requires a valid API authentication token credential for the Discord bot.
  • The bot must be running and connected via IPC (Inter-Process Communication) to receive real-time events.
  • Requires proper permissions for the bot on the selected servers and channels to listen to events.
  • Uses helper methods to load available guilds, channels, and roles dynamically for property selection.

Troubleshooting

  • No Token Given: If the API token credential is missing or invalid, the node will not connect and no events will be received. Ensure the bot token is correctly configured.
  • Channel or Guild Not Selected: Some options depend on selecting at least one server or channel. Failure to do so results in errors prompting to select these first.
  • Bot Permissions: Insufficient permissions for the bot on Discord servers/channels can prevent event detection. Verify the bot has necessary read/listen permissions.
  • IPC Connection Issues: Disconnection from the IPC server logs an error. Restarting the bot or n8n may be required.
  • Event Filtering: Misconfiguration of filters (roles, message patterns) might cause expected events not to trigger. Double-check filter criteria.
  • Workflow Activation Mode: When stopping workflows, the bot disconnects unless the activation mode is manual. Unexpected disconnections can occur if workflows are stopped externally.

Links and References

Discussion