go-twitch/api/moderation/remove_channel_vip.go

49 lines
1.4 KiB
Go
Raw Normal View History

2024-03-03 15:14:59 -05:00
package moderation
import (
"context"
"fmt"
2024-03-03 15:14:59 -05:00
"net/http"
"github.com/google/go-querystring/query"
"go.fifitido.net/twitch/api/endpoint"
2024-03-03 15:14:59 -05:00
)
type RemoveChannelVIPParams struct {
// The ID of the user to remove VIP status from.
UserID string `url:"user_id"`
// The ID of the broadcaster who owns the channel where the user has VIP status.
BroadcasterID string `url:"broadcaster_id"`
}
// Removes the specified user as a VIP in the broadcasters channel.
//
// If the broadcaster is removing the users VIP status, the ID in the broadcaster_id query parameter must match the user ID in the access token;
// otherwise, if the user is removing their VIP status themselves, the ID in the user_id query parameter must match the user ID in the access token.
//
// Rate Limits: The broadcaster may remove a maximum of 10 VIPs within a 10-second window.
//
// Requires a user access token that includes the channel:manage:vips scope.
func (m *Moderation) RemoveChannelVIP(ctx context.Context, params *RemoveChannelVIPParams) error {
v, _ := query.Values(params)
req, err := http.NewRequestWithContext(ctx, http.MethodDelete, endpoint.Make(m.baseUrl, "channels/vips", v), nil)
2024-03-03 15:14:59 -05:00
if err != nil {
return err
}
res, err := m.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 remove channel VIP (%d)", res.StatusCode)
}
2024-03-03 15:14:59 -05:00
return nil
}