glyde/model/user
The Discord user object.
One record for everyone else’s account: the wire sends the same object
with more or fewer keys, so every field that can go missing has a default.
A webhook author is the thinnest, carrying id, username and avatar.
The fields Discord gates on the identify scope live on CurrentUser,
which is the only place they are ever populated.
Types
The bot’s own account, from GET /users/@me and READY.user. Discord
gates everything below user on the identify scope, so none of it is
sent for a message author, a mention or a reaction user.
pub type CurrentUser {
CurrentUser(
user: User,
locale: option.Option(String),
flags: option.Option(flags.Flags(UserFlag)),
premium_type: option.Option(PremiumType),
mfa_enabled: Bool,
verified: option.Option(Bool),
email: option.Option(String),
)
}
Constructors
-
CurrentUser( user: User, locale: option.Option(String), flags: option.Option(flags.Flags(UserFlag)), premium_type: option.Option(PremiumType), mfa_enabled: Bool, verified: option.Option(Bool), email: option.Option(String), )Arguments
- locale
-
The account’s own language, not a guild’s.
- flags
-
The full set, including the flags
public_flagswithholds. -
Needs the
emailOAuth2 scope. A bot token never has it.
Which Nitro the account pays for.
pub type PremiumType {
NoPremium
NitroClassic
Nitro
NitroBasic
UnknownPremiumType(Int)
}
Constructors
-
NoPremium -
NitroClassic -
Nitro -
NitroBasic -
UnknownPremiumType(Int)
A Discord account: a person, a bot, or the stand-in for a webhook.
pub type User {
User(
id: id.Id(id.User),
username: String,
discriminator: String,
global_name: option.Option(String),
avatar: option.Option(String),
bot: Bool,
system: Bool,
banner: option.Option(String),
accent_color: option.Option(Int),
public_flags: option.Option(flags.Flags(UserFlag)),
avatar_decoration: option.Option(AvatarDecoration),
)
}
Constructors
-
User( id: id.Id(id.User), username: String, discriminator: String, global_name: option.Option(String), avatar: option.Option(String), bot: Bool, system: Bool, banner: option.Option(String), accent_color: option.Option(Int), public_flags: option.Option(flags.Flags(UserFlag)), avatar_decoration: option.Option(AvatarDecoration), )Arguments
- username
-
""when the payload has nousernamekey: an id and nothing else still decodes.display_namereads that empty string back asNone. - discriminator
-
Always “0” now that Discord has dropped discriminators.
- global_name
-
Display name. Null when the account has not set one.
- avatar
-
A hash, not a URL. Null when the account uses a default avatar.
- system
-
The official Discord system account.
- accent_color
-
Banner colour as 0xRRGGBB.
- avatar_decoration
-
The JSON key is
avatar_decoration_data.
pub type UserFlag {
Staff
Partner
Hypesquad
BugHunterLevel1
HypesquadOnlineHouse1
HypesquadOnlineHouse2
HypesquadOnlineHouse3
PremiumEarlySupporter
TeamPseudoUser
BugHunterLevel2
VerifiedBot
VerifiedDeveloper
CertifiedModerator
BotHttpInteractions
ActiveDeveloper
}
Constructors
-
Staff -
Partner -
Hypesquad -
BugHunterLevel1 -
HypesquadOnlineHouse1 -
HypesquadOnlineHouse2 -
HypesquadOnlineHouse3 -
PremiumEarlySupporter -
TeamPseudoUser -
BugHunterLevel2 -
VerifiedBot -
VerifiedDeveloper -
CertifiedModerator -
BotHttpInteractions -
ActiveDeveloper
pub type UserFlags =
flags.Flags(UserFlag)
Values
pub fn avatar_decoration_decoder() -> decode.Decoder(
AvatarDecoration,
)
pub fn current_user_decoder() -> decode.Decoder(CurrentUser)
The user object is not nested: its keys sit beside these six.
pub fn decoder() -> decode.Decoder(User)
pub fn display_name(account: User) -> option.Option(String)
Display name, then username. None for the empty username decoder puts
in when the key is absent, which is a payload of an id and nothing else.
pub fn has_flag(
bits: flags.Flags(UserFlag),
flag: UserFlag,
) -> Bool
pub fn premium_type_decoder() -> decode.Decoder(PremiumType)
pub fn premium_type_from_int(value: Int) -> PremiumType
pub fn premium_type_to_int(value: PremiumType) -> Int
pub fn premium_type_to_json(value: PremiumType) -> json.Json