tadpole/model/user

The Discord user object, trimmed to what a bot reads out of events. No discriminator field: modern accounts do not have one and Discord stopped sending it. global_name is the display name Discord keeps now.

Seen through tadpole/gateway/events as message.author, Ready’s user, and mention entries; a bare user also comes from endpoints.get_current_user. global_name is None until the user sets a display name, and avatar is Discord’s avatar hash — not a URL — with None meaning the default avatar. bot and system default to False: Discord omits both for ordinary users.

Types

pub type User {
  User(
    id: ids.UserId,
    username: String,
    global_name: option.Option(String),
    avatar: option.Option(String),
    bot: Bool,
    system: Bool,
  )
}

Constructors

  • User(
      id: ids.UserId,
      username: String,
      global_name: option.Option(String),
      avatar: option.Option(String),
      bot: Bool,
      system: Bool,
    )

    Arguments

    global_name

    Display name; null in Discord’s payload until the user sets one.

    avatar

    Discord’s avatar hash, not a URL. None means the default avatar.

Values

pub fn decoder() -> decode.Decoder(User)

Decoder for Discord’s user object. Discord omits bot and system for ordinary users, so both default to False when absent; global_name and avatar can arrive as null as well as absent, and both read as None either way. Unknown fields are ignored.

pub fn from_json(
  payload: String,
) -> Result(User, error.TadpoleError)

Decode a user from its JSON payload: the user object itself, not a gateway frame. Fails with error.DecodeFailed when the payload is not valid JSON, a required field is missing or mistyped, or the id is not a snowflake. The error’s event field stays None; wiring that knows the event name fills it in.

Search Document