diff --git a/lgsm/modules/alert_discord.sh b/lgsm/modules/alert_discord.sh index f3a79416a9..4c7572f29a 100644 --- a/lgsm/modules/alert_discord.sh +++ b/lgsm/modules/alert_discord.sh @@ -7,7 +7,7 @@ moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" -json=$( +jsonshortinfo=$( cat << EOF { "username":"LinuxGSM", @@ -46,8 +46,53 @@ json=$( EOF ) +jsonshortnoinfo=$( + cat << EOF +{ + "username":"LinuxGSM", + "avatar_url":"https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/alert_discord_logo.jpg", + "file":"content", + "embeds": [{ + "color": "2067276", + "author": { + "name": "${alertemoji} ${alertsubject} ${alertemoji}", + "icon_url": "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/alert_discord_logo.jpg" + }, + "title": "${servername}", + "description": "${alertbody}", + "url": "", + "type": "content", + "thumbnail": {}, + "fields": [ + { + "name": "Game", + "value": "${gamename}", + "inline": true + }, + { + "name": "Server IP", + "value": "${alertip}:${port}", + "inline": true + }, + { + "name": "Hostname", + "value": "${HOSTNAME}", + "inline": true + } + ] + }] +} +EOF +) + fn_print_dots "Sending Discord alert" +if [ "${alerturl}" == "not enabled" ]; then + json="${jsonshortnoinfo}" +else + json="${jsonshortinfo}" +fi + discordsend=$(curl --connect-timeout 10 -sSL -H "Content-Type: application/json" -X POST -d "$(echo -n "${json}" | jq -c .)" "${discordwebhook}") if [ -n "${discordsend}" ]; then