dynv6 now defaults to config, discord displays error message on error.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
# internal function to transmit a discord chunk
|
||||
# internal function to transmit a chunk of text to Discord
|
||||
function SendDiscordMessage
|
||||
{
|
||||
param (
|
||||
@@ -17,19 +17,21 @@ function SendDiscordMessage
|
||||
$botName = ConvertTo-Json -InputObject $botName
|
||||
|
||||
# rewrite json string, because "\u001b[m" needs to "\u001b[0m" instead
|
||||
# windows is fine with the missing zero, but discord needs it
|
||||
# windows is fine with the missing zero, but Discord needs it
|
||||
$message = $message -Replace "\\u001b\[m", "\u001b[0m"
|
||||
|
||||
# remove wrapping quotes around json string, replace with color-enabled block quotes
|
||||
$message = '"```ansi\n' + $message.SubString(1, $message.length - 2) + '\n```"'
|
||||
|
||||
# {"username": "$botName", "content": "$message"}
|
||||
# build post data: {"username": "$botName", "content": "$message"}
|
||||
$content = "{";
|
||||
if ($botName) {
|
||||
$content += '"username": ' + $botName + ', ';
|
||||
}
|
||||
$content += '"content": ' + $message + '}';
|
||||
|
||||
echo "$content" | curl.exe -s -H "$header" -X "POST" -d "@-" "$webhook" | ConvertFrom-Json | Select-Object -Property id | Out-Host
|
||||
# post data is complex, so we have to pipe it into curl
|
||||
# display the resulting id/message returned from Discord
|
||||
echo "$content" | curl.exe -s -H "$header" -X "POST" -d "@-" "$webhook" | ConvertFrom-Json | Select-Object -Property id, message
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user