Send discord message
Send Message to Discord
curl -H "Content-Type: application/json" -X POST -d "{\"content\": \"test from curl\"}" https://discord.com/api/webhooks/113229910/Gs0wEaVZCheck Server status and Send Message to Discord
#!/bin/bash
# Discord webhook URL
WEBHOOK_URL="https://discord.com/api/webhooks/YOUR_WEBHOOK_URL"
# Function to send a message to Discord
send_discord_message() {
local message="$1"
curl -H "Content-Type: application/json" \
-X POST \
-d "{\"content\": \"$message\"}" \
$WEBHOOK_URL
}
# Function to check for active connections
check_connections() {
# netstat -tn | grep -E '(:80|:443|:22)' | grep ESTABLISHED
ss -tn | grep -E '(:80|:443|:22)' | grep ESTAB
}
# Check for active connections and take action
if [ -z "$(check_connections)" ]; then
send_discord_message "$(date): No active connections found. Shutting down the server..."
sudo shutdown -h now
else
send_discord_message "$(date): Active connections found. Server will remain running."
fiLast updated