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:
parent
4d547d6f10
commit
7836c15cf8
|
@ -1,5 +1,7 @@
|
|||
package discord
|
||||
|
||||
import "strings"
|
||||
|
||||
type User struct {
|
||||
ID Snowflake `json:"id,string"`
|
||||
Username string `json:"username"`
|
||||
|
@ -25,6 +27,22 @@ func (u User) Mention() 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
|
||||
|
||||
const (
|
||||
|
|
Loading…
Reference in a new issue