added user struct.

This commit is contained in:
5elenay
2021-08-21 01:47:40 +03:00
parent 2b6ad70c59
commit dbfdae71e8
2 changed files with 54 additions and 0 deletions

View File

@@ -52,3 +52,23 @@ func (c Client) FetchChannel(id string) (*Channel, error) {
channel.Client = &c
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
}