Discord Trigger icon

Discord Trigger

Trigger based on Discord events

Overview

This node triggers workflows based on various Discord events. It listens to specific Discord server activities such as new messages, message updates, thread creation or updates, commands, user interactions with buttons/selects, and user-related events like joining, leaving, presence updates, nickname changes, and role modifications.

Common scenarios include:

  • Automating responses or actions when a new message is posted in certain channels.
  • Reacting to user commands issued in Discord.
  • Tracking user presence or role changes for moderation or analytics.
  • Handling button or select menu interactions within Discord messages.

For example, you could use this node to trigger a workflow that welcomes new users when they join the server, or to process custom slash commands sent by users.

Properties

Name Meaning
Listen to Select one or more text channels to listen to for triggering the workflow. If none are selected, all channels will be monitored. Requires valid credentials and an active bot.
From roles Filter events to only those involving users with specified roles. If no roles are selected, it listens to everyone (@everyone). Applies to certain event types like messages, threads, commands, and user-related events.
Trigger type The type of Discord event to listen for. Options include: New Message, Message Update, New Thread, Thread Update, Command, Interaction (button/select), User joins, User leaves, User presence update, User nick updated, User role added, User role removed.
Which roles For "User role added" or "User role removed" events, specify which roles to listen for. Defaults to listening to everyone if none selected.
Presence For "User presence update" events, specify the presence status change to listen for: Any change, Online, Offline, Do not disturb, Idle.
Pattern For message or thread events, define how to match the message content: Equals, Starts with, Contains, Ends with, Regex. The message is tested after removing mentions and trimming whitespace.
Value The string value to test against messages or threads according to the selected pattern. Required for message/thread triggers.
Name For command triggers, the name of the command to listen for (alphanumeric only). Required.
Description For command triggers, a description of the command. Required.
Input field type For command triggers, the type of input field expected: None, Text, Number, Integer, Boolean. Required.
Input field description For command triggers with an input field, a description of that field. Required if input field type is not None.
Input field required For command triggers with an input field, whether the input is required. Optional, defaults to false.
Case Sensitive For message/thread triggers, whether matching should be case sensitive. Defaults to false.
Bot Mention For message/thread triggers, require that the message also mentions the bot to trigger the workflow. Does not exclude other criteria.
Message ID For interaction triggers, the ID of the message containing the button/select to listen to. Required.
Placeholder A placeholder message shown in the channel when the workflow is running. Can be replaced by a response message from a Discord Send node.

Output

The node outputs JSON data representing the Discord event that triggered the workflow. The output includes fields such as:

  • content: The message content (for message/thread events).
  • channelId: The ID of the channel where the event occurred.
  • userId, userName, userTag: Information about the user involved.
  • messageId: The ID of the message involved.
  • presence: User presence status (if applicable).
  • nick: User's nickname (if applicable).
  • addedRoles, removedRoles: Roles added or removed from the user (if applicable).
  • interactionMessageId: For interaction events, the message ID of the button/select.
  • interactionValues: Values from the interaction.
  • userRoles: Current roles of the user.
  • attachments: Any attachments included in the message.

If binary data were supported, it would typically represent files or media attached to messages, but this node focuses on JSON event data.

Dependencies

  • Requires a valid Discord API credential with a bot token.
  • The bot must be running and connected to the Discord server.
  • The node uses an internal IPC connection to communicate with the bot process.
  • Requires at least one accessible text channel in the Discord server to listen to.
  • The node depends on n8n's HTTP webhook infrastructure to receive events.

Troubleshooting

  • No channels listed: Ensure your credentials are set correctly, the bot is running, and you have at least one text channel available. After fixing, close and reopen the modal to reload channels.
  • Commands not showing up in Discord: Verify the trigger is active and restart your Discord client.
  • Authentication errors: Check that the provided API key credential is valid and has the necessary permissions.
  • Workflow not triggering: Confirm the correct event type and filters (channels, roles, patterns) are configured.
  • Regex pattern issues: Make sure your regex is valid ECMAScript syntax.
  • Interaction triggers require correct message ID: Double-check the message ID corresponds to the button/select message.

Error messages thrown by the node generally indicate credential problems or communication failures with Discord's API and can be resolved by verifying credentials and network connectivity.

Links and References

Discussion