Overview
Theshare-discord command sends content from stdin to Discord channels via webhooks. It includes a configuration system for managing multiple webhooks and setting defaults.
Syntax
Parameters
Opens the interactive webhook configuration menu instead of sending a message.Aliases:
-cUsage Examples
Configuration Menu
Running with--configure opens an interactive menu:
Menu Options
View Webhooks- Lists all configured webhooks
- Shows which webhook is set as default
- Displays webhook URLs
- Prompts for webhook name
- Prompts for Discord webhook URL
- Option to set as default
- Validates URL format
- Shows checkbox list of webhooks
- Allows selecting multiple webhooks to remove
- Clears default if removed
- Select which webhook to use by default
- Option to clear default (will prompt each time)
- Returns to the shell
Example Configuration Session
Discord Webhook Setup
Creating a Discord Webhook
- Open Discord and go to Server Settings
- Navigate to Integrations → Webhooks
- Click “New Webhook”
- Customize the webhook name and channel
- Copy the Webhook URL
- Use the URL with
ahh share-discord --configure
Webhook URL Format
Output
When sending a message, the command displays:Color-Coded Output
- Blue: Preparing message
- White: Message length info
- Yellow: Sending status
- Green: Success confirmation
- Red: Error messages
How It Works
Webhook Selection
- If default webhook is set: Uses default automatically
- If no default: Shows selection prompt with all webhooks
- If no webhooks configured: Throws error with instructions
Message Sending
- Reads content from stdin
- Validates webhook configuration
- Constructs JSON payload:
{ "content": "message" } - Sends POST request to Discord webhook URL
- Verifies response status
Error Handling
No Webhooks Configured404: Webhook not found (deleted or invalid URL)429: Rate limited (too many requests)400: Bad request (malformed payload)
Configuration Storage
Webhooks are stored in the Ahh configuration file at~/.ahh/config.json:
Message Limitations
Discord messages are limited to 2,000 characters. Messages exceeding this limit will fail with a 400 error.
Advanced Usage
Automation Scripts
Monitoring
CI/CD Integration
Technical Details
Implementation
Built using:- @inquirer/prompts - Interactive CLI prompts
- fetch API - HTTP requests to Discord
- Ahh config system - Persistent webhook storage
Webhook Validation
URL validation ensures:- Starts with
https://discord.com/api/webhooks/ - Prevents accidental invalid URLs
- Provides helpful error messages
Interactive Prompts
- select: Choose from menu options
- checkbox: Multi-select for removal
- input: Text entry with validation
- confirm: Yes/no questions
