go-twitch/api/chat/update_user_chat_color.go

44 lines
1.3 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package chat
import (
"context"
"net/http"
"net/url"
"github.com/google/go-querystring/query"
)
type UpdateUserChatColorParams struct {
// The ID of the user whose chat color you want to update. This ID must match the user ID in the access token.
UserID string `url:"user_id"`
// The color to use for the user's name in chat. All users may specify one of the following named color values:
//
// blue, blue_violet, cadet_blue, chocolate, coral, dodger_blue, firebrick
// golden_rod, green, hot_pink, orange_red, red, sea_green, spring_green, yellow_green
//
// Turbo and Prime users may specify a named color or a Hex color code like #9146FF. If you use a Hex color code, remember to URL encode it.
Color string `url:"color"`
}
// Updates the color used for the users name in chat.
//
// Requires a user access token that includes the user:manage:chat_color scope.
func (c *Chat) UpdateUserChatColor(ctx context.Context, params *UpdateUserChatColorParams) error {
v, _ := query.Values(params)
endpoint := c.baseUrl.ResolveReference(&url.URL{Path: "chat/color", RawQuery: v.Encode()})
req, err := http.NewRequestWithContext(ctx, http.MethodPut, 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
}