2020-01-02 19:53:08 +00:00
|
|
|
package discord
|
2020-01-02 05:39:52 +00:00
|
|
|
|
2020-01-24 06:00:41 +00:00
|
|
|
import "strings"
|
|
|
|
|
2020-04-15 03:52:48 +00:00
|
|
|
// DefaultAvatarURL is the link to the default green avatar on Discord. It's
|
|
|
|
// returned from AvatarURL() if the user doesn't have an avatar.
|
|
|
|
var DefaultAvatarURL = "https://discordapp.com/assets/dd4dbc0016779df1378e7812eabaa04d.png"
|
|
|
|
|
2020-01-02 05:39:52 +00:00
|
|
|
type User struct {
|
2020-01-04 04:19:24 +00:00
|
|
|
ID Snowflake `json:"id,string"`
|
2020-01-02 19:53:08 +00:00
|
|
|
Username string `json:"username"`
|
|
|
|
Discriminator string `json:"discriminator"`
|
|
|
|
Avatar Hash `json:"avatar"`
|
2020-01-02 05:39:52 +00:00
|
|
|
|
|
|
|
// These fields may be omitted
|
|
|
|
|
|
|
|
Bot bool `json:"bot,omitempty"`
|
|
|
|
MFA bool `json:"mfa_enabled,omitempty"`
|
|
|
|
|
|
|
|
DiscordSystem bool `json:"system,omitempty"`
|
|
|
|
EmailVerified bool `json:"verified,omitempty"`
|
|
|
|
|
|
|
|
Locale string `json:"locale,omitempty"`
|
|
|
|
Email string `json:"email,omitempty"`
|
|
|
|
|
|
|
|
Flags UserFlags `json:"flags,omitempty"`
|
2020-01-04 04:19:24 +00:00
|
|
|
Nitro UserNitro `json:"premium_type,omitempty"`
|
2020-01-02 05:39:52 +00:00
|
|
|
}
|
|
|
|
|
2020-01-24 05:45:47 +00:00
|
|
|
func (u User) Mention() string {
|
|
|
|
return "<@" + u.ID.String() + ">"
|
|
|
|
}
|
|
|
|
|
2020-01-24 06:00:41 +00:00
|
|
|
func (u User) AvatarURL() string {
|
|
|
|
if u.Avatar == "" {
|
2020-04-15 03:52:48 +00:00
|
|
|
return DefaultAvatarURL
|
2020-01-24 06:00:41 +00:00
|
|
|
}
|
|
|
|
|
2020-04-15 03:52:48 +00:00
|
|
|
base := "https://cdn.discordapp.com"
|
2020-01-24 06:00:41 +00:00
|
|
|
base += "/avatars/" + u.ID.String() + "/" + u.Avatar
|
|
|
|
|
|
|
|
if strings.HasPrefix(u.Avatar, "a_") {
|
|
|
|
return base + ".gif"
|
|
|
|
} else {
|
|
|
|
return base + ".png"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-02 05:39:52 +00:00
|
|
|
type UserFlags uint16
|
|
|
|
|
|
|
|
const (
|
|
|
|
NoFlag UserFlags = 0
|
|
|
|
|
|
|
|
DiscordEmployee UserFlags = 1 << iota
|
|
|
|
DiscordPartner
|
|
|
|
HypeSquadEvents
|
|
|
|
BugHunter
|
|
|
|
HouseBravery
|
|
|
|
HouseBrilliance
|
|
|
|
HouseBalance
|
|
|
|
EarlySupporter
|
|
|
|
TeamUser
|
|
|
|
System
|
|
|
|
)
|
|
|
|
|
2020-01-04 04:19:24 +00:00
|
|
|
type UserNitro uint8
|
2020-01-02 05:39:52 +00:00
|
|
|
|
|
|
|
const (
|
2020-01-04 04:19:24 +00:00
|
|
|
NoUserNitro UserNitro = iota
|
2020-01-02 05:39:52 +00:00
|
|
|
NitroClassic
|
|
|
|
NitroFull
|
|
|
|
)
|
2020-01-07 06:45:29 +00:00
|
|
|
|
|
|
|
type Connection struct {
|
|
|
|
ID Snowflake `json:"id"`
|
|
|
|
Name string `json:"name"`
|
|
|
|
Type Service `json:"type"`
|
|
|
|
|
|
|
|
Revoked bool `json:"revoked"`
|
|
|
|
Verified bool `json:"verified"`
|
|
|
|
FriendSync bool `json:"friend_sync"`
|
|
|
|
ShowActivity bool `json:"show_activity"`
|
|
|
|
|
|
|
|
Visibility ConnectionVisibility `json:"visibility"`
|
|
|
|
|
|
|
|
// Only partial
|
2020-01-15 07:34:18 +00:00
|
|
|
Integrations []Integration `json:"integrations"`
|
2020-01-07 06:45:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type ConnectionVisibility uint8
|
|
|
|
|
|
|
|
const (
|
|
|
|
ConnectionNotVisible ConnectionVisibility = iota
|
|
|
|
ConnectionVisibleEveryone
|
|
|
|
)
|
2020-01-18 21:04:12 +00:00
|
|
|
|
|
|
|
type Status string
|
|
|
|
|
|
|
|
const (
|
|
|
|
UnknownStatus Status = ""
|
|
|
|
OnlineStatus Status = "online"
|
|
|
|
DoNotDisturbStatus Status = "dnd"
|
|
|
|
IdleStatus Status = "idle"
|
|
|
|
InvisibleStatus Status = "invisible"
|
|
|
|
OfflineStatus Status = "offline"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Activity struct {
|
|
|
|
Name string `json:"name"`
|
|
|
|
Type ActivityType `json:"type"`
|
2020-03-31 05:50:46 +00:00
|
|
|
URL URL `json:"url,omitempty"`
|
2020-01-18 21:04:12 +00:00
|
|
|
|
|
|
|
// User only
|
|
|
|
|
2020-03-31 05:50:46 +00:00
|
|
|
CreatedAt UnixTimestamp `json:"created_at,omitempty"`
|
2020-03-31 05:46:34 +00:00
|
|
|
Timestamps *ActivityTimestamp `json:"timestamps,omitempty"`
|
2020-01-18 21:04:12 +00:00
|
|
|
|
|
|
|
ApplicationID Snowflake `json:"application_id,omitempty"`
|
|
|
|
Details string `json:"details,omitempty"`
|
|
|
|
State string `json:"state,omitempty"` // party status
|
2020-03-31 05:46:34 +00:00
|
|
|
Emoji *Emoji `json:"emoji,omitempty"`
|
2020-01-18 21:04:12 +00:00
|
|
|
|
2020-03-31 05:46:34 +00:00
|
|
|
Party *ActivityParty `json:"party,omitempty"`
|
|
|
|
Assets *ActivityAssets `json:"assets,omitempty"`
|
|
|
|
Secrets *ActivitySecrets `json:"secrets,omitempty"`
|
2020-01-18 21:04:12 +00:00
|
|
|
|
|
|
|
Instance bool `json:"instance,omitempty"`
|
|
|
|
Flags ActivityFlags `json:"flags,omitempty"`
|
2020-02-23 17:56:16 +00:00
|
|
|
|
|
|
|
// Undocumented fields
|
|
|
|
SyncID string `json:"sync_id,omitempty"`
|
|
|
|
SessionID string `json:"session_id,omitempty"`
|
2020-01-18 21:04:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type ActivityType uint8
|
|
|
|
|
|
|
|
const (
|
|
|
|
// Playing $name
|
|
|
|
GameActivity ActivityType = iota
|
|
|
|
// Streaming $details
|
|
|
|
StreamingActivity
|
|
|
|
// Listening to $name
|
|
|
|
ListeningActivity
|
2020-02-24 02:20:13 +00:00
|
|
|
_
|
|
|
|
// $emoji $state
|
2020-01-18 21:04:12 +00:00
|
|
|
CustomActivity
|
|
|
|
)
|
|
|
|
|
|
|
|
type ActivityFlags uint8
|
|
|
|
|
|
|
|
const (
|
|
|
|
InstanceActivity ActivityFlags = 1 << iota
|
|
|
|
JoinActivity
|
|
|
|
SpectateActivity
|
|
|
|
JoinRequestActivity
|
|
|
|
SyncActivity
|
|
|
|
PlayActivity
|
|
|
|
)
|
2020-03-31 05:00:28 +00:00
|
|
|
|
2020-03-31 05:46:34 +00:00
|
|
|
type ActivityTimestamp struct {
|
|
|
|
Start UnixMsTimestamp `json:"start,omitempty"`
|
|
|
|
End UnixMsTimestamp `json:"end,omitempty"`
|
|
|
|
}
|
|
|
|
|
2020-03-31 05:00:28 +00:00
|
|
|
type ActivityParty struct {
|
|
|
|
ID string `json:"id,omitempty"`
|
|
|
|
Size [2]int `json:"size,omitempty"` // [ current, max ]
|
|
|
|
}
|
|
|
|
|
|
|
|
type ActivityAssets struct {
|
|
|
|
LargeImage string `json:"large_image,omitempty"` // id
|
|
|
|
LargeText string `json:"large_text,omitempty"`
|
|
|
|
SmallImage string `json:"small_image,omitempty"` // id
|
|
|
|
SmallText string `json:"small_text,omitempty"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type ActivitySecrets struct {
|
|
|
|
Join string `json:"join,omitempty"`
|
|
|
|
Spectate string `json:"spectate,omitempty"`
|
|
|
|
Match string `json:"match,omitempty"`
|
|
|
|
}
|