tadpole/model/guild

The Discord guild (server) object, trimmed to identification. Guild payloads are enormous and vary by endpoint; later milestones widen this record as REST wiring needs more of it.

Two records for two payloads:

Types

pub type Guild {
  Guild(
    id: ids.GuildId,
    name: String,
    member_count: option.Option(Int),
  )
}

Constructors

  • Guild(
      id: ids.GuildId,
      name: String,
      member_count: option.Option(Int),
    )

    Arguments

    member_count

    None in payloads that omit the count, such as unavailable guilds arriving through READY.

Guild on a READY payload that the bot has not received GUILD_CREATE for yet (a technical outage). Only the id is guaranteed; everything else waits for the real GUILD_CREATE.

pub type UnavailableGuild {
  UnavailableGuild(id: ids.GuildId)
}

Constructors

Values

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

Decoder for Discord’s guild object. Discord sends IDs as strings; a non-snowflake string in id fails the decode. Unknown fields are ignored.

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

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

pub fn unavailable_decoder() -> decode.Decoder(UnavailableGuild)

Decoder for one entry in READY’s guilds array. unavailable may be absent, so it is not modeled as a field — everything READY lists here starts unavailable until GUILD_CREATE lands.

pub fn unavailable_from_json(
  payload: String,
) -> Result(UnavailableGuild, error.TadpoleError)

Decode one entry of READY’s guilds array. Fails with error.DecodeFailed when the payload is not valid JSON or the id is not a snowflake.

Search Document