1
0
Fork 0
mirror of https://github.com/diamondburned/arikawa.git synced 2024-11-15 19:33:17 +00:00

Added User AvatarURL

This commit is contained in:
diamondburned (Forefront) 2020-01-23 22:00:41 -08:00
parent 4d547d6f10
commit 7836c15cf8

View file

@ -1,5 +1,7 @@
package discord package discord
import "strings"
type User struct { type User struct {
ID Snowflake `json:"id,string"` ID Snowflake `json:"id,string"`
Username string `json:"username"` Username string `json:"username"`
@ -25,6 +27,22 @@ func (u User) Mention() string {
return "<@" + u.ID.String() + ">" return "<@" + u.ID.String() + ">"
} }
func (u User) AvatarURL() string {
base := "https://cdn.discordapp.com"
if u.Avatar == "" {
return base + "/embed/avatars/" + u.Discriminator + ".png"
}
base += "/avatars/" + u.ID.String() + "/" + u.Avatar
if strings.HasPrefix(u.Avatar, "a_") {
return base + ".gif"
} else {
return base + ".png"
}
}
type UserFlags uint16 type UserFlags uint16
const ( const (