Discord Interaction icon

Discord Interaction

Sends messages, embeds and prompts to Discord

Overview

The Discord Interaction node enables sending various types of interactions to a Discord server via a bot. It supports sending plain messages, embedded rich content, confirmation prompts, and performing specific actions such as removing messages or managing user roles within a Discord guild (server).

Common scenarios where this node is useful include:

  • Sending announcements or updates to a Discord channel with rich formatting.
  • Prompting users for confirmation before proceeding with an automated workflow.
  • Moderation tasks like bulk deleting recent messages in a channel.
  • Managing user roles by adding or removing roles programmatically.

For example, you could use this node to send a welcome message with an embed when a new user joins, ask for confirmation before executing a critical operation, or automatically remove spam messages from a channel.

Properties

Name Meaning
Type Choose the type of interaction:
Action: Perform an action like removing messages or modifying user roles.
Message: Send a simple text or embed message.
Confirmation: Ask the user to confirm or cancel.
Action When Type is "Action", select the specific action:
• Remove Messages
• Add Role to User
• Remove Role From User
Server Name or ID Select or specify the Discord guild (server) where the action/message will be performed.
Channel Name or ID Select or specify the text channel within the guild where the message will be sent or the action applied.
How Many? Number of last messages to remove (only for Remove Messages action). Max 100.
User ID The Discord user ID to add or remove roles from (for role management actions).
Which Role Names or IDs Roles to add or remove from the specified user (for role management actions).
Content Text content of the message or confirmation prompt. Required if using buttons or select prompts.
Embed Whether to send the message as an embed instead of plain text.
Color Color of the embed sidebar (if embed is enabled).
Title Title of the embed message.
URL URL linked to the embed title.
Author Name Name shown as the author of the embed.
Author Icon URL or Base64 Image URL or base64 string for the author's icon in the embed.
Author URL URL linked to the author name in the embed.
Description Description text inside the embed.
Thumbnail URL or Base64 URL or base64 image shown as the embed thumbnail.
Fields Custom fields inside the embed, each with a title, value, and inline display option.
Image URL or Base64 Main image displayed in the embed.
Footer Text Footer text of the embed.
Footer Icon URL or Base64 Image URL or base64 string for the footer icon.
Displayed Date Timestamp shown in the embed footer.
Files Attach up to 5 images (URLs or base64) to the message (only for message or confirmation types).
Mention Role Names or IDs Roles to mention/tag in the message.

Output

The node outputs JSON data containing details about the interaction result. Typical output fields include:

  • value: The main response or result value from the interaction.
  • channelId: The ID of the channel where the interaction occurred.
  • userId: The ID of the user involved (if applicable).
  • userName, userTag: Username and tag of the user involved.
  • messageId: The ID of the message sent or affected.
  • action: The action performed (e.g., role added, messages removed).

If the node sends messages with attachments, it handles image URLs/base64 strings but does not output binary data directly.

For confirmation prompts, the output indicates whether the user confirmed, canceled, or did not respond.

Dependencies

  • Requires a valid Discord bot API credential with appropriate permissions to send messages, manage roles, and delete messages in the target guild.
  • The bot must be running and connected to the Discord servers.
  • Uses a socket connection to communicate with the bot process for sending commands and receiving callbacks.
  • Requires n8n environment configured with the Discord bot API key credential.

Troubleshooting

  • No channels or roles listed: Ensure you have selected at least one guild/server before trying to load channels or roles. Also, verify that the bot has access to those guilds and the necessary permissions.
  • Connection errors: If the node cannot connect to the bot, check that the bot is running and reachable. Network issues or incorrect credentials can cause failures.
  • Permission errors: Actions like removing messages or managing roles require the bot to have sufficient permissions in the guild. Verify the bot's role and permissions.
  • Invalid IDs: When specifying user, role, or channel IDs manually, ensure they are correct and exist in the selected guild.
  • Message removal limits: Discord API only allows bulk deletion of messages younger than 2 weeks and up to 100 messages at once. Setting higher values or older messages will fail.
  • Empty content with buttons/select: When using confirmation prompts or interactive messages, the content field cannot be empty.

Links and References

Discussion