added fetch bans.
This commit is contained in:
parent
db57751adf
commit
7506d1c0bb
36
server.go
36
server.go
@ -58,6 +58,18 @@ type FetchedMembers struct {
|
|||||||
Users []*User `json:"users"`
|
Users []*User `json:"users"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fetched bans struct.
|
||||||
|
type FetchedBans struct {
|
||||||
|
Users []*User `json:"users"`
|
||||||
|
Bans []struct {
|
||||||
|
Ids struct {
|
||||||
|
UserId string `json:"user"`
|
||||||
|
ServerUd string `json:"server"`
|
||||||
|
} `json:"_id"`
|
||||||
|
Reason string `json:"reason"`
|
||||||
|
} `json:"bans"`
|
||||||
|
}
|
||||||
|
|
||||||
// Calculate creation date and edit the struct.
|
// Calculate creation date and edit the struct.
|
||||||
func (s *Server) CalculateCreationDate() error {
|
func (s *Server) CalculateCreationDate() error {
|
||||||
ulid, err := ulid.Parse(s.Id)
|
ulid, err := ulid.Parse(s.Id)
|
||||||
@ -233,6 +245,30 @@ func (s Server) UnbanMember(id string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fetch server bans.
|
||||||
|
func (s Server) FetchBans() (*FetchedBans, error) {
|
||||||
|
bans := &FetchedBans{}
|
||||||
|
|
||||||
|
data, err := s.Client.Request("GET", "/servers/"+s.Id+"/bans", []byte{})
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return bans, err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = json.Unmarshal(data, bans)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return bans, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add client to the user
|
||||||
|
for _, i := range bans.Users {
|
||||||
|
i.Client = s.Client
|
||||||
|
}
|
||||||
|
|
||||||
|
return bans, nil
|
||||||
|
}
|
||||||
|
|
||||||
// // Fetch all server invites.
|
// // Fetch all server invites.
|
||||||
// func (s Server) FetchInvites() {
|
// func (s Server) FetchInvites() {
|
||||||
// data, _ := s.Client.Request("GET", "/servers/"+s.Id+"/invites", []byte{})
|
// data, _ := s.Client.Request("GET", "/servers/"+s.Id+"/invites", []byte{})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user