Discord Trigger icon

Discord Trigger

Discord Trigger on message

Overview

The Discord Trigger node listens to various Discord server events and triggers workflows in n8n when those events occur. It is useful for automating responses or actions based on real-time Discord activity, such as messages sent in channels, reactions added or removed, role changes, and user join/leave events.

Common scenarios include:

  • Automating moderation or logging when users join or leave a server.
  • Responding to specific messages or commands sent in Discord channels.
  • Tracking role creation, deletion, or updates for audit purposes.
  • Reacting to message reactions to trigger further workflows.

For example, you could use this node to start a workflow whenever a user sends a message starting with "!help" in a particular channel, or to log every time a new role is created on your server.

Properties

Name Meaning
Trigger Type The type of Discord event to listen for. Options include: Message, Reaction Add, Reaction Remove, Role Add, Role Delete, Role Update, User Join, User Leave.
Server Names or IDs Select one or more Discord servers (guilds) to listen to. You can choose from a list or specify server IDs using expressions.
Listen To Channels For message and reaction events, select which text channels to listen to. If none selected, all channels are listened to.
Listen to Roles For message and reaction events, optionally filter by roles. If no roles are selected, it listens to everyone (@everyone).
Listen to Message For reaction add/remove events, specify a message ID to only trigger on reactions to that message.
Pattern For message events, define how the message content is matched: Bot Mention, Contains, Ends With, Equals, Every message, Regex, Starts With.
Value The string or regex pattern to match against messages (used with certain Pattern options).
Case Sensitive Whether the message matching is case sensitive.
Trigger Only on Message Replies Whether to trigger only if the message is a reply to another message. The replied-to message will be included in the output.
Message ID For interaction events (e.g., button/select), specify the message ID to listen to.
Additional Fields Optional additional settings:
• Trigger on Other Bot Input — whether to trigger on messages sent by other bots.
• Attachment(s) Required — require at least one attachment to trigger.

Output

The node outputs JSON data representing the event details when triggered. The structure varies depending on the event type:

  • Message events: Includes message ID, content, guild ID, channel ID, author info (ID, username, bot status), timestamp, and optionally referenced message details if it's a reply. Attachments are included if present.
  • Reaction add/remove: Includes reaction details merged with user info, channel ID, and guild ID.
  • Role events: Outputs role data for create, delete, or update events. For updates, both old and new role properties are provided with keys prefixed accordingly.
  • User join/leave: Outputs the guild member object representing the user joining or leaving.

If binary data were involved (e.g., attachments), it would be summarized here, but this node primarily outputs JSON event data.

Dependencies

  • Requires a valid API authentication token credential for the Discord bot.
  • The Discord bot must be running and connected via IPC (Inter-Process Communication).
  • The bot needs appropriate permissions on the specified servers and channels to receive events.
  • The node dynamically loads available servers, channels, and roles via helper methods.
  • No external services beyond Discord's API and the bot connection are required.

Troubleshooting

  • No token given / invalid credentials: The node will not connect without a valid API token. Ensure the credential is configured correctly.
  • No servers selected: When selecting channels or roles, at least one server must be chosen first; otherwise, an error is thrown.
  • Bot not running or disconnected: The node relies on the bot being connected via IPC. If disconnected, events won't trigger.
  • Channels or roles not loading: This may happen if the bot lacks permissions or the modal was opened before the bot was ready. Try closing and reopening the node configuration.
  • Trigger not firing: Check that the event type matches the actual Discord event, and filters like channels, roles, message IDs, or patterns are set correctly.
  • Case sensitivity issues: If matching messages, verify the "Case Sensitive" option aligns with your expected input.
  • Attachment requirement: If enabled, the trigger will ignore messages without attachments.

Links and References

Discussion