Move non @me methods higher, modify UserGuilds.

This commit is contained in:
Chris Rhodes 2016-01-10 21:23:15 -08:00
parent fc9dc56e25
commit d52e39a592

View file

@ -179,6 +179,22 @@ func (s *Session) User(userID string) (st *User, err error) {
return
}
// UserAvatar returns an image.Image of a users Avatar
// userID : A user ID or "@me" which is a shortcut of current user ID
func (s *Session) UserAvatar(userID string) (img image.Image, err error) {
u, err := s.User(userID)
if err != nil {
return
}
body, err := s.Request("GET", USER_AVATAR(userID, u.Avatar), nil)
if err != nil {
return nil, err
}
img, _, err = image.Decode(bytes.NewReader(body))
return
}
// UserUpdate updates a users settings.
func (s *Session) UserUpdate(email, password, username, avatar, newPassword string) (st *User, err error) {
@ -200,22 +216,6 @@ func (s *Session) UserUpdate(email, password, username, avatar, newPassword stri
return
}
// UserAvatar returns an image.Image of a users Avatar
// userID : A user ID or "@me" which is a shortcut of current user ID
func (s *Session) UserAvatar(userID string) (img image.Image, err error) {
u, err := s.User(userID)
if err != nil {
return
}
body, err := s.Request("GET", USER_AVATAR(userID, u.Avatar), nil)
if err != nil {
return nil, err
}
img, _, err = image.Decode(bytes.NewReader(body))
return
}
// UserSettings returns the settings for a given user
func (s *Session) UserSettings(userID string) (st *Settings, err error) {
@ -248,9 +248,9 @@ func (s *Session) UserChannelCreate(recipientID string) (st *Channel, err error)
}
// UserGuilds returns an array of Guild structures for all guilds.
func (s *Session) UserGuilds(userID string) (st []*Guild, err error) {
func (s *Session) UserGuilds() (st []*Guild, err error) {
body, err := s.Request("GET", USER_GUILDS(userID), nil)
body, err := s.Request("GET", USER_GUILDS("@me"), nil)
err = json.Unmarshal(body, &st)
return
}