@theredflag/n8n-nodes-custom-discord
v2.0.0
Published
Discord community node for getting all messages from channels with customizable rate limiting
Readme
Discord Get All Messages - n8n Community Node
A custom n8n community node package for retrieving all messages from Discord channels with advanced rate limiting and pagination control.
Features
- Get All Messages: Retrieve all messages from any Discord channel your bot has access to
- Customizable Rate Limiting: Control the delay between API requests to avoid hitting Discord's rate limits
- Flexible Pagination: Support for pagination with
before,after, andaroundmessage ID parameters - Response Simplification: Option to return simplified message data or full Discord API response
- Built-in Error Handling: Graceful error handling with continue-on-fail support
Installation
Via n8n Community Nodes
- Go to Settings > Community Nodes in your n8n instance
- Click Install a community node
- Enter the package name:
@theredflag/n8n-nodes-discord-purge - Click Install
Via npm (for self-hosted n8n)
npm install @theredflag/n8n-nodes-discord-purgeThen restart your n8n instance.
Prerequisites
You need a Discord Bot Token to use this node. If you don't have one:
- Go to the Discord Developer Portal
- Create a new application
- Go to the "Bot" section
- Create a bot and copy the token
- Invite the bot to your server with appropriate permissions
Configuration
Credentials
This package includes the Discord Bot API credential type:
- Bot Token: Your Discord bot's token (keep this secure!)
Node Parameters
Required Parameters
- Channel ID: The ID of the Discord channel to fetch messages from
Optional Parameters
- Return All: Whether to fetch all messages or limit the results (default: true)
- Limit: Maximum number of messages to return when "Return All" is false (1-100, default: 50)
Advanced Options
- After Message ID: Get messages after this specific message ID
- Around Message ID: Get messages around this specific message ID
- Before Message ID: Get messages before this specific message ID
- Delay Between Requests (Ms): Time in milliseconds to wait between API requests (default: 1000ms)
- Simplify Response: Return simplified message data instead of full Discord API response (default: true)
Usage Examples
Basic Usage - Get All Messages
- Add the "Discord Get All Messages" node to your workflow
- Configure your Discord Bot API credentials
- Enter the Channel ID (e.g.,
123456789012345678) - Set "Return All" to
true - Execute the workflow
Rate-Limited Bulk Retrieval
For large channels, use a longer delay to avoid rate limits:
- Set "Delay Between Requests (Ms)" to
2000(2 seconds) - This helps when fetching thousands of messages from active channels
Paginated Retrieval
To get messages from a specific time range:
- Set "Before Message ID" to a message ID from your end date
- Set "After Message ID" to a message ID from your start date
- This will fetch messages between those two points
Output Data
Simplified Response (default)
When "Simplify Response" is enabled, each message contains:
id: Message IDchannel_id: Channel ID where the message was sentauthor: Author information (user object)content: Message text contenttimestamp: When the message was createdtype: Message typeattachments: File attachmentsembeds: Rich embedsreactions: Message reactionsmentions: User/role mentionsedited_timestamp: When the message was last edited (if applicable)
Full Response
When "Simplify Response" is disabled, you get the complete Discord API message object with all fields.
Rate Limiting
Discord has strict rate limits:
- Global: 50 requests per second across all endpoints
- Per-channel: Varies by endpoint, typically 5-10 requests per second
This node includes built-in rate limiting:
- Default 1-second delay between requests
- Respects Discord's rate limit headers
- Automatically handles rate limit responses
For very large channels (10k+ messages), consider:
- Increasing delay to 2-3 seconds
- Running during off-peak hours
- Using pagination to process in chunks
Permissions Required
Your Discord bot needs the following permissions in the target channel:
- Read Messages (
VIEW_CHANNEL) - Read Message History (
READ_MESSAGE_HISTORY)
Limitations
- Maximum 100 messages per API request (Discord limitation)
- Historical message limit depends on Discord's retention policy
- Bot can only access channels it has permissions for
- Rate limits may slow down large bulk operations
Troubleshooting
Common Issues
"Missing Permissions" Error
- Ensure your bot has the required permissions in the target channel
- Check that the bot is actually in the server/channel
Rate Limit Errors
- Increase the "Delay Between Requests" value
- Consider running during off-peak hours
Invalid Channel ID
- Right-click the channel in Discord and select "Copy ID"
- Ensure Developer Mode is enabled in Discord settings
Empty Results
- Check if the channel has any messages
- Verify the bot can see the channel
- Check if using pagination parameters correctly
Getting Channel IDs
- Enable Developer Mode in Discord (User Settings > Advanced > Developer Mode)
- Right-click on the channel name
- Select "Copy ID"
Support
If you encounter issues or have questions:
- Check the n8n community forum
- Report bugs via the GitHub repository
License
MIT License - see LICENSE file for details.
Contributing
Contributions are welcome! Please feel free to submit pull requests or open issues on the GitHub repository.
