-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathaudit_log.go
42 lines (35 loc) · 960 Bytes
/
audit_log.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
package rest
import (
"context"
"fmt"
"net/http"
"net/url"
"github.com/Postcord/objects"
"github.com/google/go-querystring/query"
)
type GetAuditLogParams struct {
UserID objects.Snowflake `url:"user_id,omitempty"`
ActionType objects.AuditLogEvent `url:"action_type,omitempty"`
Before objects.Snowflake `url:"before,omitempty"`
Limit int `url:"limit,omitempty"`
}
func (c *Client) GetAuditLogs(ctx context.Context, guild objects.SnowflakeObject, params *GetAuditLogParams) (*objects.AuditLog, error) {
u, err := url.Parse(fmt.Sprintf(GuildAuditLogsFmt, guild.GetID()))
if err != nil {
return nil, err
}
q, err := query.Values(params)
if err != nil {
return nil, err
}
u.RawQuery = q.Encode()
entries := &objects.AuditLog{}
err = NewRequest().
Method(http.MethodGet).
WithContext(ctx).
Path(u.String()).
ContentType(JsonContentType).
Bind(entries).
Send(c)
return entries, err
}