I'm trying to automate listing players in a game server to Discord using webhooks and curl.
Some variables are:
$PREPLAY defined as PREPLAY=__Currently Connected:__ this adds the text underlined
$MESSAGE defined as MESSAGE="Current Online Count: \"$NOWCOUNT\" (this works, but had to edit for stackoverflow markup)
$NOWCOUNT defined by other script (This also works)
$PLAYERS (the list of players) - I'll get more into this in a second
The line I'm using is:
curl -H "Content-Type: application/json" -X POST -d "{\"embeds\": [{ \"color\": \"45044\", \"description\": \"$PREPLAY$PLAYERS\", \"title\": \"$MESSAGE\" }]}" $URL
when I use:
PLAYERS=$(cat /tmp/players.list | sed '/Players connected/q' | egrep -v '^$' | egrep -v "^LOG" | sed -e 's/^-/\\\\\\n/')
The output in Discord comes out as
Notice the extra "\"
Or if, I remove ONE "\" from the variable assignment above to be:
PLAYERS=$(cat /tmp/players.list | sed '/Players connected/q' | egrep -v '^$' | egrep -v "^LOG" | sed -e 's/^-/\\\\\n/')
I get a JSON error:
OK, removing TWO "/"s and the new-lines just don't work:


