From e7c751826dc85433d7e28e5133a97303a25dd2ac Mon Sep 17 00:00:00 2001 From: Andrew Stowell Date: Fri, 10 Nov 2023 22:00:07 +0000 Subject: [PATCH] discord.sh handles empty message gracefully. --- discord.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/discord.sh b/discord.sh index 2a7accc..5154796 100755 --- a/discord.sh +++ b/discord.sh @@ -126,7 +126,13 @@ fi # linux is fine with the missing zero, but discord needs it message=$(echo "$message" | jq -aRs . | sed 's/\\u001b\[m/\\u001b[0m/g') -message="\"\`\`\`ansi\n${message:1:-1}\n\`\`\`\"" +if [[ "$message" = '"\n"' ]]; then + # message empty, so denote as such + message='"\ud83d\udea9 MESSAGE EMPTY \ud83d\udea9"' +else + # wrap message into "ansi" block, for text color support + message="\"\`\`\`ansi\n${message:1:-1}\n\`\`\`\"" +fi # handle distinct stuff oldMsg=""