added fetch server function

This commit is contained in:
5elenay committed 2021-08-23 08:29:11 +03:00
1 parent b9c3edb138
commit 4147d56df4
2 files changed
+25

No files matched your search

+20
View File
@@ -101,3 +101,23 @@ func (c *Client) FetchUser(id string) (*User, error) {
return user, nil return user, nil
} }
// Fetch a server by Id.
func (c *Client) FetchServer(id string) (*Server, error) {
server := &Server{}
server.Client = c
data, err := c.Request("GET", "/servers/"+id, []byte{})
if err != nil {
return server, err
}
err = json.Unmarshal(data, server)
if err != nil {
return server, err
}
return server, nil
}
+5
View File
@@ -1,7 +1,12 @@
package revoltgo package revoltgo
import "time"
// Server struct. // Server struct.
type Server struct { type Server struct {
Client *Client
CreatedAt time.Time
Id string `json:"_id"` Id string `json:"_id"`
Nonce string `json:"nonce"` Nonce string `json:"nonce"`
OwnerId string `json:"owner"` OwnerId string `json:"owner"`