go-twitch/api/raids/cancel_a_raid.go

34 lines
882 B
Go
Raw Normal View History

2024-03-03 16:00:12 -05:00
package raids
import (
"context"
"net/http"
"net/url"
)
// 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 (c *Raids) CancelARaid(ctx context.Context, broadcasterID string) error {
endpoint := c.baseUrl.ResolveReference(&url.URL{Path: "raids", RawQuery: url.Values{"broadcaster_id": {broadcasterID}}.Encode()})
req, err := http.NewRequestWithContext(ctx, http.MethodDelete, endpoint.String(), nil)
if err != nil {
return err
}
res, err := c.client.Do(req)
if err != nil {
return err
}
defer res.Body.Close()
return nil
}