Skip to content

Commit

Permalink
fix ids
Browse files Browse the repository at this point in the history
  • Loading branch information
gempir committed May 26, 2024
1 parent a32b93d commit bebd7fa
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions internal/server/fossabot.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,26 +89,26 @@ func (a *Api) HandlePrediction(context FossabotContext, w http.ResponseWriter, r
}

func (h *Api) lockOrCancelPrediction(context FossabotContext, status string) string {
resp, err := h.helixClient.GetPredictions(&helix.PredictionsParams{BroadcasterID: context.Channel.ID})
resp, err := h.helixClient.GetPredictions(&helix.PredictionsParams{BroadcasterID: context.Channel.ProviderID})
if err != nil {
log.Error(err)
return err.Error()
}
prediction := resp.Data.Predictions[0]

token, err := h.db.GetUserAccessToken(context.Channel.ID)
token, err := h.db.GetUserAccessToken(context.Channel.ProviderID)
if err != nil {
return err.Error()
}
h.helixClient.SetUserAccessToken(token.AccessToken)
resp, err = h.helixClient.EndPrediction(&helix.EndPredictionParams{BroadcasterID: context.Channel.ID, ID: prediction.ID, Status: status})
resp, err = h.helixClient.EndPrediction(&helix.EndPredictionParams{BroadcasterID: context.Channel.ProviderID, ID: prediction.ID, Status: status})
h.helixClient.SetUserAccessToken("")

if err != nil {
log.Error(err)
return err.Error()
}
log.Infof("[helix] %d CancelOrLockPrediction %s", resp.StatusCode, context.Channel.ID)
log.Infof("[helix] %d CancelOrLockPrediction %s", resp.StatusCode, context.Channel.ProviderID)
if resp.StatusCode >= http.StatusBadRequest {
return fmt.Sprintf("Bad Twitch API response %d", resp.StatusCode)
}
Expand All @@ -121,7 +121,7 @@ func (h *Api) setOutcomeForPrediction(context FossabotContext) string {

var winningOutcome helix.Outcomes

resp, err := h.helixClient.GetPredictions(&helix.PredictionsParams{BroadcasterID: context.Channel.ID})
resp, err := h.helixClient.GetPredictions(&helix.PredictionsParams{BroadcasterID: context.Channel.ProviderID})
if err != nil {
log.Error(err)
return err.Error()
Expand All @@ -139,7 +139,7 @@ func (h *Api) setOutcomeForPrediction(context FossabotContext) string {
return "outcome not found"
}

_, err = h.helixClient.EndPrediction(&helix.EndPredictionParams{BroadcasterID: context.Channel.ID, ID: prediction.ID, Status: dto.PredictionStatusResolved, WinningOutcomeID: winningOutcome.ID})
_, err = h.helixClient.EndPrediction(&helix.EndPredictionParams{BroadcasterID: context.Channel.ProviderID, ID: prediction.ID, Status: dto.PredictionStatusResolved, WinningOutcomeID: winningOutcome.ID})
if err != nil {
log.Error(err)
return fmt.Sprintf("failed to end prediction: %s", err.Error())
Expand Down Expand Up @@ -189,7 +189,7 @@ func (h *Api) startPrediction(context FossabotContext) string {
}

prediction := &helix.CreatePredictionParams{
BroadcasterID: context.Channel.ID,
BroadcasterID: context.Channel.ProviderID,
Title: title,
Outcomes: outcomes,
PredictionWindow: predictionWindow,
Expand Down

0 comments on commit bebd7fa

Please sign in to comment.