Skip to content

Commit

Permalink
Lets actaully test my changes and fix what I broke!
Browse files Browse the repository at this point in the history
  • Loading branch information
BarryCarlyon committed Sep 24, 2021
1 parent ef71e6f commit adefb2d
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions internal/events/trigger/trigger_event.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ package trigger

import (
"fmt"
"log"
"io/ioutil"
"time"

"github.com/fatih/color"
"github.com/twitchdev/twitch-cli/internal/database"
"github.com/twitchdev/twitch-cli/internal/events"
"github.com/twitchdev/twitch-cli/internal/events/types"
Expand Down Expand Up @@ -117,12 +118,18 @@ func Fire(p TriggerParameters) (string, error) {
}
defer resp.Body.Close()

body, err := ioutil.ReadAll(resp.Body)
if err != nil {
return "", err
}

respTrigger := string(body)
if resp.StatusCode >= 200 && resp.StatusCode <= 299 {
color.New().Add(color.FgGreen).Println(fmt.Sprintf(`✔ Request Sent. Recieved Status Code: %v`, resp.StatusCode))
color.New().Add(color.FgGreen).Println(fmt.Sprintf(`✔ Server Said: %s`, resp.Body))
color.New().Add(color.FgGreen).Println(fmt.Sprintf(`✔ Server Said: %s`, respTrigger))
} else {
color.New().Add(color.FgRed).Println(fmt.Sprintf(`✗ Invalid response. Recieved Status Code: %v`, resp.StatusCode))
color.New().Add(color.FgRed).Println(fmt.Sprintf(`✗ Server Said: %s`, resp.Body))
color.New().Add(color.FgRed).Println(fmt.Sprintf(`✗ Server Said: %s`, respTrigger))
}
}

Expand Down

0 comments on commit adefb2d

Please sign in to comment.