added user struct.
This commit is contained in:
parent
2b6ad70c59
commit
dbfdae71e8
20
client.go
20
client.go
@ -52,3 +52,23 @@ func (c Client) FetchChannel(id string) (*Channel, error) {
|
|||||||
channel.Client = &c
|
channel.Client = &c
|
||||||
return channel, nil
|
return channel, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fetch an user by Id.
|
||||||
|
func (c Client) FetchUser(id string) (*User, error) {
|
||||||
|
user := &User{}
|
||||||
|
|
||||||
|
data, err := c.Request("GET", "/users/"+id, []byte{})
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return user, err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = json.Unmarshal(data, user)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return user, err
|
||||||
|
}
|
||||||
|
|
||||||
|
user.Client = &c
|
||||||
|
return user, nil
|
||||||
|
}
|
||||||
|
34
user.go
Normal file
34
user.go
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
package revoltgo
|
||||||
|
|
||||||
|
// User struct.
|
||||||
|
type User struct {
|
||||||
|
Client *Client
|
||||||
|
|
||||||
|
Id string `json:"_id"`
|
||||||
|
Username string `json:"username"`
|
||||||
|
Avatar *Attachment `json:"avatar"`
|
||||||
|
Relations []*UserRelations `json:"relations"`
|
||||||
|
Badges int `json:"badges"`
|
||||||
|
Status *UserStatus `json:"status"`
|
||||||
|
Relationship string `json:"relationship"`
|
||||||
|
IsOnline bool `json:"online"`
|
||||||
|
Flags int `json:"flags"`
|
||||||
|
BotInformation *BotInformation `json:"bot"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// User relations struct.
|
||||||
|
type UserRelations struct {
|
||||||
|
Id string `json:"_id"`
|
||||||
|
Status string `json:"status"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// User status struct.
|
||||||
|
type UserStatus struct {
|
||||||
|
Text string `json:"text"`
|
||||||
|
Presence string `json:"presence"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Bot information struct.
|
||||||
|
type BotInformation struct {
|
||||||
|
Owner string `json:"owner"`
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user