go-twitch/api/chat/send_shoutout.go

56 lines
2.1 KiB
Go
Raw Normal View History

2024-02-28 10:30:20 -05:00
package chat
import (
"context"
"net/http"
"net/url"
"github.com/google/go-querystring/query"
)
type SendShoutoutParams struct {
// The ID of the broadcaster thats sending the Shoutout.
FromBroadcasterID string `url:"from_broadcaster_id"`
// The ID of the broadcaster thats receiving the Shoutout.
ToBroadcasterID string `url:"to_broadcaster_id"`
// The ID of the broadcaster or a user that is one of the broadcasters moderators.
// This ID must match the user ID in the access token.
ModeratorID string `url:"moderator_id"`
}
// Sends a Shoutout to the specified broadcaster.
// Typically, you send Shoutouts when you or one of your moderators notice another broadcaster in your chat,
// the other broadcaster is coming up in conversation, or after they raid your broadcast.
//
// Twitchs Shoutout feature is a great way for you to show support for other broadcasters and help them grow.
// Viewers who do not follow the other broadcaster will see a pop-up Follow button in your chat that they can click to follow the other broadcaster.
// Learn More: https://help.twitch.tv/s/article/shoutouts
//
// Rate Limits The broadcaster may send a Shoutout once every 2 minutes.
// They may send the same broadcaster a Shoutout once every 60 minutes.
//
// To receive notifications when a Shoutout is sent or received, subscribe to the channel.shoutout.create and channel.shoutout.receive subscription types.
// The channel.shoutout.create event includes cooldown periods that indicate when the broadcaster may send another
// Shoutout without exceeding the endpoints rate limit.
//
// Requires a user access token that includes the moderator:manage:shoutouts scope.
func (c *Chat) SendShoutout(ctx context.Context, params *SendShoutoutParams) error {
v, _ := query.Values(params)
endpoint := c.baseUrl.ResolveReference(&url.URL{Path: "chat/shoutouts", RawQuery: v.Encode()})
req, err := http.NewRequestWithContext(ctx, http.MethodPost, 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
}