forked from nicklaw5/helix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmoderation.go
48 lines (41 loc) · 1.24 KB
/
moderation.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package helix
// Ban ...
// ExpiresAt must be parsed manually since an empty string means perma ban
type Ban struct {
UserID string `json:"user_id"`
UserLogin string `json:"user_login"`
UserName string `json:"user_name"`
ExpiresAt Time `json:"expires_at"`
}
// ManyBans ...
type ManyBans struct {
Bans []Ban `json:"data"`
Pagination Pagination `json:"pagination"`
}
// BannedUsersResponse ...
type BannedUsersResponse struct {
ResponseCommon
Data ManyBans
}
// BannedUsersParams ...
// BroadcasterID must match the auth tokens user_id
type BannedUsersParams struct {
BroadcasterID string `query:"broadcaster_id"`
UserID string `query:"user_id"`
After string `query:"after"`
Before string `query:"before"`
}
// GetBannedUsers returns all banned and timed-out users in a channel.
//
// Required scope: moderation:read
func (c *Client) GetBannedUsers(params *BannedUsersParams) (*BannedUsersResponse, error) {
resp, err := c.get("/moderation/banned", &ManyBans{}, params)
if err != nil {
return nil, err
}
bans := &BannedUsersResponse{}
resp.HydrateResponseCommon(&bans.ResponseCommon)
bans.Data.Bans = resp.Data.(*ManyBans).Bans
bans.Data.Pagination = resp.Data.(*ManyBans).Pagination
return bans, nil
}