mirror of
https://github.com/diamondburned/arikawa.git
synced 2024-11-16 03:44:26 +00:00
Added User AvatarURL
This commit is contained in:
parent
4d547d6f10
commit
7836c15cf8
|
@ -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 (
|
||||||
|
|
Loading…
Reference in a new issue