Last active
June 18, 2024 08:19
-
-
Save apfzvd/300346dae55190e022ee49a1001d26af to your computer and use it in GitHub Desktop.
how to send a message to discord channel using the webhook via shell script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
## | |
# Discord Webhook | |
# Change the 'your_discord_webhook_name' with your actual Discord Webhook | |
## | |
## | |
# add to linux cron: | |
# sudo crontab -e | |
# https://crontab.guru/ | |
## | |
discord_url="your_discord_webhook_name" | |
generate_post_data() { | |
cat <<EOF | |
{ | |
"content": "Hello! World!", | |
"embeds": [{ | |
"title": "Embeded Title", | |
"description": "Description", | |
"color": "45973" | |
}] | |
} | |
EOF | |
} | |
# POST request to Discord Webhook | |
curl -H "Content-Type: application/json" -X POST -d "$(generate_post_data)" $discord_url |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you, OP. I drew inspiration and adopted a generalized approach: