5
0
mirror of https://github.com/cwinfo/matterbridge.git synced 2024-12-30 19:45:40 +00:00
matterbridge/vendor/github.com/bwmarrin/discordgo/user.go

48 lines
1.2 KiB
Go
Raw Normal View History

2017-07-16 12:38:45 +00:00
package discordgo
import (
"fmt"
"strings"
)
2017-07-16 12:38:45 +00:00
// 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 fmt.Sprintf("%s#%s", u.Username, u.Discriminator)
}
// Mention return a string which mentions the user
func (u *User) Mention() string {
return fmt.Sprintf("<@%s>", u.ID)
}
// AvatarURL returns a URL to the user's avatar.
2018-02-14 21:22:35 +00:00
// size: The size of the user's avatar as a power of two
// if size is an empty string, no size parameter will
// be added to the URL.
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)
}
2018-02-14 21:22:35 +00:00
if size != "" {
return URL + "?size=" + size
}
return URL
}