#[non_exhaustive]pub struct CurrentUser {Show 19 fields
pub id: UserId,
pub username: CompactString,
pub discriminator: u16,
pub global_name: Option<CompactString>,
pub avatar: Option<ImageHash>,
pub bot: bool,
pub system: bool,
pub mfa_enabled: bool,
pub banner: Option<ImageHash>,
pub accent_color: Option<u32>,
pub locale: Option<Locale>,
pub verified: bool,
pub email: Option<CompactString>,
pub flags: Option<UserFlags>,
pub premium_type: Option<PremiumType>,
pub public_flags: Option<UserFlags>,
pub avatar_decoration_data: Option<Box<AvatarDecorationData>>,
pub collectibles: Option<Box<Collectibles>>,
pub primary_guild: Option<Box<PrimaryGuild>>,
}Expand description
The user account the client is logged in as, with the fields Discord only sends for it (D-052).
Received in Ready and from GET /users/@me. With an
OAuth2 bearer token, email and verified require the email scope. Bots receive these
fields too (email is then None).
See the user object.
discord.js counterpart: ClientUser.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.id: UserIdThe user’s ID.
username: CompactStringThe user’s username.
discriminator: u16The legacy four-digit Discord tag, or 0 for migrated users. See
User::discriminator.
global_name: Option<CompactString>The user’s display name, if set.
avatar: Option<ImageHash>The user’s avatar hash.
bot: boolWhether the user is a bot.
system: boolWhether the user is an official Discord system user.
mfa_enabled: boolWhether the account has two-factor authentication enabled.
The user’s banner hash.
accent_color: Option<u32>The banner color as an RGB integer (0xRRGGBB).
locale: Option<Locale>The language the user chose in the client.
verified: boolWhether the account’s email address is verified.
email: Option<CompactString>The account’s email address (OAuth2 email scope; always None for bots).
flags: Option<UserFlags>All flags on the account, including non-public ones.
The account’s Nitro subscription.
public_flags: Option<UserFlags>The public flags (badges).
avatar_decoration_data: Option<Box<AvatarDecorationData>>The user’s avatar decoration.
collectibles: Option<Box<Collectibles>>The user’s collectibles.
primary_guild: Option<Box<PrimaryGuild>>The guild whose server tag the user displays.
Implementations§
Source§impl CurrentUser
impl CurrentUser
Sourcepub fn display_name(&self) -> &str
pub fn display_name(&self) -> &str
Returns the global display name if set, otherwise the username.
discord.js counterpart: User#displayName.
Sourcepub fn tag(&self) -> CompactString
pub fn tag(&self) -> CompactString
Returns the tag: username#1234 for legacy users, username for migrated users.
discord.js counterpart: User#tag.
Trait Implementations§
Source§impl Clone for CurrentUser
impl Clone for CurrentUser
Source§impl Debug for CurrentUser
impl Debug for CurrentUser
Source§impl<'de> Deserialize<'de> for CurrentUser
impl<'de> Deserialize<'de> for CurrentUser
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for CurrentUser
Source§impl From<CurrentUser> for User
impl From<CurrentUser> for User
Source§fn from(user: CurrentUser) -> Self
fn from(user: CurrentUser) -> Self
Keeps the fields every user has and drops the account-only ones.