123456789101112131415161718192021222324252627282930313233343536373839 |
- package discordgo
- import "strings"
- // A User stores all data for an individual Discord user.
- type User struct {
- ID string `json:"id"`
- Email string `json:"email"`
- Username string `json:"username"`
- Avatar string `json:"avatar"`
- Discriminator string `json:"discriminator"`
- Token string `json:"token"`
- Verified bool `json:"verified"`
- MFAEnabled bool `json:"mfa_enabled"`
- Bot bool `json:"bot"`
- }
- // String returns a unique identifier of the form username#discriminator
- func (u *User) String() string {
- return u.Username + "#" + u.Discriminator
- }
- // Mention return a string which mentions the user
- func (u *User) Mention() string {
- return "<@" + u.ID + ">"
- }
- // AvatarURL returns a URL to the user's avatar.
- // size: The size of the user's avatar as a power of two
- func (u *User) AvatarURL(size string) string {
- var URL string
- if strings.HasPrefix(u.Avatar, "a_") {
- URL = EndpointUserAvatarAnimated(u.ID, u.Avatar)
- } else {
- URL = EndpointUserAvatar(u.ID, u.Avatar)
- }
- return URL + "?size=" + size
- }
|