#!/bin/bash set -e send() { local _msg=$1 if [[ -z $_msg ]]; then return fi curl -X POST \ -H "Content-Type: application/json" \ -d "{\"content\":\"$_msg\"}" \ "$DISCORD_WEBHOOK" } msg="" while IFS= read -r line; do if [[ ${#msg}${#line} -ge 2000 ]]; then send "$msg" msg="" else msg+="$line" fi done send "$msg"