package raids import ( "context" "fmt" "net/http" "net/url" "go.fifitido.net/twitch/api/endpoint" ) // Cancel a pending raid. // // You can cancel a raid at any point up until the broadcaster clicks Raid Now in the Twitch UX or the 90-second countdown expires. // // Rate Limit: The limit is 10 requests within a 10-minute window. // // Requires a user access token that includes the channel:manage:raids scope. // // The broadcaster ID must match the user ID in the user access token. func (r *Raids) CancelARaid(ctx context.Context, broadcasterID string) error { v := url.Values{"broadcaster_id": {broadcasterID}} req, err := http.NewRequestWithContext(ctx, http.MethodDelete, endpoint.Make(r.baseUrl, "raids", v), nil) if err != nil { return err } res, err := r.client.Do(req) if err != nil { return err } defer res.Body.Close() statusOK := res.StatusCode >= 200 && res.StatusCode < 300 if !statusOK { return fmt.Errorf("failed to cancel a raid (%d)", res.StatusCode) } return nil }