diff --git a/lgsm/modules/alert_discord.sh b/lgsm/modules/alert_discord.sh index 3b489984d1..c58bcdc0bd 100644 --- a/lgsm/modules/alert_discord.sh +++ b/lgsm/modules/alert_discord.sh @@ -8,7 +8,7 @@ moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" json=$( - cat << EOF + cat << EOF { "username": "LinuxGSM", "avatar_url": "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/alert_discord_logo.jpg", @@ -46,12 +46,25 @@ json=$( "name": "Server Time", "value": "$(date)", "inline": true - }, + } +EOF +) + +if [ -n "${querytype}" ]; then + json+=$( + cat << EOF + , { "name": "Is my Game Server Online?", "value": "https://ismygameserver.online/${imgsoquerytype}/${alertip}:${queryport}", "inline": true } +EOF + ) +fi + +json+=$( + cat << EOF ], "footer": { "icon_url": "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/alert_discord_logo.jpg", @@ -63,6 +76,9 @@ json=$( EOF ) +echo "${json}" +) + fn_print_dots "Sending Discord alert" discordsend=$(curl --connect-timeout 3 -sSL -H "Content-Type: application/json" -X POST -d "$(echo -n "${json}" | jq -c .)" "${discordwebhook}")