package chat import ( "context" "fmt" "net/http" "net/url" "github.com/google/go-querystring/query" ) type SendShoutoutParams struct { // The ID of the broadcaster that’s sending the Shoutout. FromBroadcasterID string `url:"from_broadcaster_id"` // The ID of the broadcaster that’s receiving the Shoutout. ToBroadcasterID string `url:"to_broadcaster_id"` // The ID of the broadcaster or a user that is one of the broadcaster’s 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. // // Twitch’s 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 endpoint’s 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() statusOK := res.StatusCode >= 200 && res.StatusCode < 300 if !statusOK { return fmt.Errorf("failed to send shoutout (%d)", res.StatusCode) } return nil }