mirror of
https://github.com/Luzifer/twitch-bot.git
synced 2024-12-20 20:01:17 +00:00
[twitch] Implement AddChannelVIP
, RemoveChannelVIP
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
29ce8820bf
commit
f0dfea1728
1 changed files with 46 additions and 0 deletions
|
@ -10,6 +10,29 @@ import (
|
|||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
func (c *Client) AddChannelVIP(ctx context.Context, broadcasterName, userName string) error {
|
||||
broadcaster, err := c.GetIDForUsername(broadcasterName)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "getting ID for broadcaster name")
|
||||
}
|
||||
|
||||
userID, err := c.GetIDForUsername(userName)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "getting ID for user name")
|
||||
}
|
||||
|
||||
return errors.Wrap(
|
||||
c.request(clientRequestOpts{
|
||||
AuthType: authTypeBearerToken,
|
||||
Context: ctx,
|
||||
Method: http.MethodPost,
|
||||
OKStatus: http.StatusNoContent,
|
||||
URL: fmt.Sprintf("https://api.twitch.tv/helix/channels/vips?broadcaster_id=%s&user_id=%s", broadcaster, userID),
|
||||
}),
|
||||
"executing request",
|
||||
)
|
||||
}
|
||||
|
||||
func (c *Client) ModifyChannelInformation(ctx context.Context, broadcasterName string, game, title *string) error {
|
||||
if game == nil && title == nil {
|
||||
return errors.New("netiher game nor title provided")
|
||||
|
@ -83,3 +106,26 @@ func (c *Client) ModifyChannelInformation(ctx context.Context, broadcasterName s
|
|||
"executing request",
|
||||
)
|
||||
}
|
||||
|
||||
func (c *Client) RemoveChannelVIP(ctx context.Context, broadcasterName, userName string) error {
|
||||
broadcaster, err := c.GetIDForUsername(broadcasterName)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "getting ID for broadcaster name")
|
||||
}
|
||||
|
||||
userID, err := c.GetIDForUsername(userName)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "getting ID for user name")
|
||||
}
|
||||
|
||||
return errors.Wrap(
|
||||
c.request(clientRequestOpts{
|
||||
AuthType: authTypeBearerToken,
|
||||
Context: ctx,
|
||||
Method: http.MethodDelete,
|
||||
OKStatus: http.StatusNoContent,
|
||||
URL: fmt.Sprintf("https://api.twitch.tv/helix/channels/vips?broadcaster_id=%s&user_id=%s", broadcaster, userID),
|
||||
}),
|
||||
"executing request",
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue