-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrest_guilds.go
47 lines (37 loc) · 1.11 KB
/
rest_guilds.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
package tatsu_api
import (
"context"
"golang.org/x/xerrors"
)
func (rc *restClient) getGuildMemberPoints(ctx context.Context, guildID string, userID string) (*GuildMemberPoints, error) {
// Validate input.
if guildID == "" {
return nil, xerrors.New("guild id was empty")
}
if userID == "" {
return nil, xerrors.New("user id was empty")
}
var points *GuildMemberPoints
err := rc.get(ctx, getGuildMemberPoints(guildID, userID), &points)
return points, err
}
func (rc *restClient) modifyGuildMemberScore(ctx context.Context, guildID string, userID string, action Action,
amount uint32) (*GuildMemberScore, error) {
// Validate input.
if guildID == "" {
return nil, xerrors.New("guild id was empty")
}
if userID == "" {
return nil, xerrors.New("user id was empty")
}
if amount < 1 || amount > 100000 {
return nil, xerrors.New("the amount to modify must be between 1 and 100,000 inclusive")
}
// Make request.
var score *GuildMemberScore
err := rc.patch(ctx, modifyGuildMemberScore(guildID, userID), &modifyGuildMemberScoreReq{
Action: action,
Amount: amount,
}, &score)
return score, err
}