glyde/model/role

Guild roles.

Types

pub type Role {
  Role(
    id: id.Id(id.Role),
    name: String,
    colors: RoleColors,
    hoist: Bool,
    icon: option.Option(String),
    unicode_emoji: option.Option(String),
    position: Int,
    permissions: permissions.Permissions,
    managed: Bool,
    mentionable: Bool,
    tags: option.Option(RoleTags),
    flags: flags.Flags(RoleFlag),
  )
}

Constructors

  • Role(
      id: id.Id(id.Role),
      name: String,
      colors: RoleColors,
      hoist: Bool,
      icon: option.Option(String),
      unicode_emoji: option.Option(String),
      position: Int,
      permissions: permissions.Permissions,
      managed: Bool,
      mentionable: Bool,
      tags: option.Option(RoleTags),
      flags: flags.Flags(RoleFlag),
    )

    Arguments

    id

    The @everyone role carries the guild’s own id.

    colors

    The one colour field. Discord still sends the deprecated color, and the decoder reads it only to fill this in when colors is missing, so there is no second number here to disagree with.

    hoist

    Listed separately in the member sidebar.

    icon

    Absent without the ROLE_ICONS feature, null on a role with no icon.

    position

    Ties are broken by id.

    permissions

    Guild-wide. The permissions on members and channels are not.

    managed

    Owned by an integration, so it cannot be assigned or deleted.

    tags

    Absent on an ordinary role.

The three shapes Discord accepts. Anything else is a 400, so three numbers that can disagree would be three ways to get one. Gradient and Holographic need the ENHANCED_ROLE_COLORS feature.

pub type RoleColors {
  Solid(primary: Int)
  Gradient(primary: Int, secondary: Int)
  Holographic
}

Constructors

  • Solid(primary: Int)
  • Gradient(primary: Int, secondary: Int)
  • Holographic

    Discord accepts one holographic triple and no other, so this carries no numbers: role_colors_to_json writes them.

pub type RoleFlag {
  InPrompt
}

Constructors

  • InPrompt

    The role can be picked in an onboarding prompt.

The three booleans are a present null for true and no key for false, so they are decoded by presence and not by value.

pub type RoleTags {
  RoleTags(
    bot_id: option.Option(id.Id(id.User)),
    integration_id: option.Option(id.Id(id.Integration)),
    subscription_listing_id: option.Option(
      id.Id(id.SubscriptionListing),
    ),
    premium_subscriber: Bool,
    available_for_purchase: Bool,
    guild_connections: Bool,
  )
}

Constructors

Values

pub fn decoder() -> decode.Decoder(Role)
pub fn has_flag(
  bits: flags.Flags(RoleFlag),
  flag: RoleFlag,
) -> Bool
pub fn is_gradient(colors: RoleColors) -> Bool
pub fn role_colors_decoder() -> decode.Decoder(RoleColors)
pub fn role_colors_to_json(colors: RoleColors) -> json.Json

Every key, every time: a null clears a colour, and omitting the key keeps whatever the role already has.

pub fn role_tags_decoder() -> decode.Decoder(RoleTags)
pub fn role_tags_to_json(tags: RoleTags) -> json.Json
Search Document