forked from pothtonswer/discordmuffin
UserAvatar to accept user object. (#337)
* UserAvatar to accept user object. One of the most important thing with this library is that it does 1 request per function. You have 100% control over how many web requests get made. UserAvatar breaks that. UserAvatar now accepts a user, which not only makes you know how many web requests gets made, but might also save on web requests if you have an existing user object. * Removed dots. Please work, travis :< * Ohhh... A friend spotted the error! * `go fmt` and fixed comment... PLS TRAVIS
This commit is contained in:
parent
b7f00b390a
commit
d4f874c0f4
1 changed files with 8 additions and 2 deletions
10
restapi.go
10
restapi.go
|
@ -262,15 +262,21 @@ func (s *Session) User(userID string) (st *User, err error) {
|
|||
return
|
||||
}
|
||||
|
||||
// UserAvatar returns an image.Image of a users Avatar.
|
||||
// UserAvatar is deprecated. Please use UserAvatarDecode
|
||||
// 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
|
||||
}
|
||||
img, err = s.UserAvatarDecode(u)
|
||||
return
|
||||
}
|
||||
|
||||
body, err := s.RequestWithBucketID("GET", EndpointUserAvatar(userID, u.Avatar), nil, EndpointUserAvatar("", ""))
|
||||
// UserAvatarDecode returns an image.Image of a user's Avatar
|
||||
// user : The user which avatar should be retrieved
|
||||
func (s *Session) UserAvatarDecode(u *User) (img image.Image, err error) {
|
||||
body, err := s.RequestWithBucketID("GET", EndpointUserAvatar(u.ID, u.Avatar), nil, EndpointUserAvatar("", ""))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue