From 2317bade0bbd9ba16062aac70279b55798b3211b Mon Sep 17 00:00:00 2001 From: Thijs Stobbelaar Date: Wed, 11 Oct 2023 11:09:45 +0200 Subject: [PATCH] bug fix --- discord/report_new_matches.ps1 | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/discord/report_new_matches.ps1 b/discord/report_new_matches.ps1 index a4ed1f2..0f03abb 100644 --- a/discord/report_new_matches.ps1 +++ b/discord/report_new_matches.ps1 @@ -73,9 +73,15 @@ foreach ($winid in $new_win_matches) { if ($null -eq $winid) { continue } $winmatches = $player_matches.player_matches | Where-Object { $_.id -eq $winid } $telemetry = (invoke-webrequest @($winmatches.telemetry_url)[0]).content | convertfrom-json | where-object { ($_._T -eq 'LOGPLAYERTAKEDAMAGE') -or ($_._T -eq 'LOGPLAYERKILLV2') } - $players = $winmatches.stats.name + $players = ($winmatches | where-object {$_.stats.winPlace -eq 1}).stats.name $match_stats = Invoke-RestMethod -Uri "https://api.pubg.com/shards/steam/matches/$winid" -Method GET -Headers $headers - $all_winners_of_match = ($match_stats.included.attributes.stats | where-object { $_.winplace -eq 1 }) + if($winmatches[0].matchType -eq 'custom'){ + $all_winners_of_match = $match_stats.included.attributes.stats + }else{ + $all_winners_of_match = ($match_stats.included.attributes.stats | where-object { $_.winplace -eq 1 }) + } + + send-discord -content ":chicken: :chicken: **WINNER WINNER CHICKEN DINNER!!** :chicken: :chicken:" send-discord -content ":partying_face::partying_face::partying_face: Gefeliciteerd $($players -join ', ') :partying_face::partying_face::partying_face:" $match_settings = @" @@ -83,10 +89,12 @@ foreach ($winid in $new_win_matches) { match mode $($winmatches[0].gameMode) match type $($winmatches[0].matchType) map $($map_map[$winmatches[0].mapName]) +id $($winmatches[0].id) `````` "@ send-discord -content $match_settings foreach ($player in $all_winners_of_match.name) { + if($null -eq $player){continue} write-output "creating table for player $player" $win_stats += [PSCustomObject]@{ Name = $player