Delete Channel Message
Deletes a specific message from a Discord channel.
Common Properties
- Name - The custom name of the node.
- Color - The custom color of the node.
- Delay Before (sec) - Waits in seconds before executing the node.
- Delay After (sec) - Waits in seconds after executing node.
- Continue On Error - Automation will continue regardless of any error. The default value is false.
If the ContinueOnError property is true, no error is caught when the project is executed, even if a Catch node is used.
Inputs
- Client Id - The Discord bot client identifier from the Connect node (optional if Bot Token provided).
- Channel Id - The ID of the Discord channel containing the message.
- Message Id - The ID of the message to delete.
Options
- Bot Token - Discord bot token credential (optional if using Client ID from Connect node).
How It Works
The Delete Channel Message node removes a specific message from a Discord channel. When executed, the node:
- Authenticates using either Client ID or direct bot token
- Validates the channel ID and message ID
- Sends a delete message request to Discord API
- Permanently removes the message
Requirements
- Active Discord bot session (Client ID) or bot token credentials
- Valid channel ID and message ID
- Appropriate permissions (see below)
- The message must exist and not already be deleted
Error Handling
The node will return specific errors in the following cases:
- ErrInvalidArg - Client ID or bot token missing/invalid
- ErrInvalidArg - Channel ID is empty
- ErrInvalidArg - Message ID is empty
- Discord API errors (message not found, missing permissions, etc.)
Permission Requirements
To delete messages, the bot needs:
- Manage Messages - To delete other users' messages
- OR the message was sent by the bot itself (can always delete own messages)
Example: Delete Bot's Own Message
Inputs:
- Channel Id: "123456789012345678"
- Message Id: "111111111111111111"
Result: The message is deleted (no special permission needed if it's the bot's message).
Example: Moderation - Delete Spam
Flow:
1. Receive Message → message
2. Condition: message.Content contains "spam"
3. If True:
- Delete Channel Message
- Channel Id: {{message.ChannelID}}
- Message Id: {{message.ID}}
Result: Automatically delete messages containing spam.
Example: Auto-Delete Commands
Flow:
1. Receive Message → message
2. Condition: message.Content starts with "!"
3. Process command
4. Send response
5. Delete Channel Message (original command)
- Channel Id: {{message.ChannelID}}
- Message Id: {{message.ID}}
Result: Keep channels clean by removing command messages after processing.
Example: Timed Message Deletion
Flow:
1. Send Channel Message → sent_message
2. Delay 10 seconds
3. Delete Channel Message
- Message Id: {{sent_message.ID}}
Result: Send a temporary message that deletes itself after 10 seconds.
Use Cases
- Content moderation - Remove inappropriate or spam messages
- Bot cleanup - Delete bot command messages
- Temporary messages - Send messages that auto-delete
- Error correction - Remove incorrectly sent messages
- Privacy - Remove messages containing sensitive information
- Channel maintenance - Clean up old or irrelevant messages
Message Deletion Rules
- Messages can only be deleted if they're less than 14 days old for bulk operations
- Individual message deletion works on any message age
- Deleted messages cannot be recovered
- The bot must have appropriate permissions
- Pinned messages can be deleted (if permissions allow)
Bot Permissions Required
- Manage Messages - To delete other users' messages
- No special permission needed to delete the bot's own messages
Rate Limits
Discord has rate limits for message deletion:
- Deleting many messages quickly may hit rate limits
- Consider using bulk delete for multiple messages
- Add delays between deletions in loops
Bulk Deletion
For deleting multiple messages:
- Use Discord's bulk delete API (not available in this node)
- Or loop through messages with delays
- Bulk delete is faster but limited to messages less than 14 days old
Tips and Best Practices
- Verify permissions - Check bot has Manage Messages before attempting
- Message age - Be aware of 14-day limit for some operations
- User experience - Consider user impact before deleting messages
- Logging - Log deleted messages for audit trails
- Error handling - Handle cases where message is already deleted
- Moderation - Use deletion sparingly and fairly
- Alternative - Consider editing offensive content instead of deleting