glyde/model/guild

Guilds, called servers everywhere except the API. One record covers GET /guilds/{id}, GUILD_CREATE and GUILD_UPDATE.

The GUILD_CREATE-only block is one Option, never seven. None is REST, where the question does not apply; a GatewayCreate holding empty lists is a gateway create with nothing visible. A cache that conflates them wipes itself.

GUILD_CREATE and GUILD_DELETE read unavailable by opposite rules.

Types

Both counts or neither: with_counts=true answers with the pair, and no request produces one without the other.

pub type ApproximateCounts {
  ApproximateCounts(members: Int, presences: Int)
}

Constructors

  • ApproximateCounts(members: Int, presences: Int)
pub type Ban {
  Ban(reason: option.Option(String), user: user.User)
}

Constructors

pub type ExplicitContentFilterLevel {
  FilterDisabled
  FilterMembersWithoutRoles
  FilterAllMembers
  UnknownExplicitContentFilterLevel(Int)
}

Constructors

  • FilterDisabled
  • FilterMembersWithoutRoles
  • FilterAllMembers
  • UnknownExplicitContentFilterLevel(Int)

The block only GUILD_CREATE sends. It arrives together, so the fields are plain: there is no guild that knows its member count and not its channels.

pub type GatewayCreate {
  GatewayCreate(
    joined_at: String,
    large: Bool,
    member_count: Int,
    voice_states: List(voice_state.VoiceState),
    members: List(member.GuildMember),
    channels: List(channel.Channel),
    threads: List(channel.Channel),
  )
}

Constructors

  • GatewayCreate(
      joined_at: String,
      large: Bool,
      member_count: Int,
      voice_states: List(voice_state.VoiceState),
      members: List(member.GuildMember),
      channels: List(channel.Channel),
      threads: List(channel.Channel),
    )

    Arguments

    joined_at

    ISO-8601, when the bot joined.

    voice_states

    Partial: these voice states carry no guild_id.

    members

    Without the GUILD_MEMBERS intent, only the bot and the users in voice. Truncated regardless above 75 000 members.

    threads

    Active threads the bot can see, not every thread.

pub type Guild {
  Guild(
    id: id.Id(id.Guild),
    name: String,
    icon: option.Option(String),
    icon_hash: option.Option(String),
    splash: option.Option(String),
    discovery_splash: option.Option(String),
    owner_id: id.Id(id.User),
    afk_channel_id: option.Option(id.Id(id.Channel)),
    afk_timeout: Int,
    widget_enabled: option.Option(Bool),
    widget_channel_id: option.Option(id.Id(id.Channel)),
    verification_level: VerificationLevel,
    default_message_notifications: MessageNotificationLevel,
    explicit_content_filter: ExplicitContentFilterLevel,
    roles: List(role.Role),
    emojis: List(emoji.GuildEmoji),
    features: List(String),
    mfa_level: MfaLevel,
    application_id: option.Option(id.Id(id.Application)),
    system_channel_id: option.Option(id.Id(id.Channel)),
    system_channel_flags: flags.Flags(SystemChannelFlag),
    rules_channel_id: option.Option(id.Id(id.Channel)),
    max_presences: option.Option(Int),
    max_members: option.Option(Int),
    vanity_url_code: option.Option(String),
    description: option.Option(String),
    banner: option.Option(String),
    premium_tier: PremiumTier,
    premium_subscription_count: option.Option(Int),
    preferred_locale: String,
    public_updates_channel_id: option.Option(id.Id(id.Channel)),
    max_video_channel_users: option.Option(Int),
    max_stage_video_channel_users: option.Option(Int),
    counts: option.Option(ApproximateCounts),
    nsfw_level: GuildNsfwLevel,
    premium_progress_bar_enabled: Bool,
    safety_alerts_channel_id: option.Option(id.Id(id.Channel)),
    gateway_create: option.Option(GatewayCreate),
  )
}

Constructors

GUILD_DELETE’s payload is one of these. A GuildOutage is Discord losing the guild, so the cache keeps it; a GuildGone is the bot kicked, banned or leaving, so the cache drops it.

pub type GuildDeparture {
  GuildOutage(id.Id(id.Guild))
  GuildGone(id.Id(id.Guild))
}

Constructors

pub type GuildNsfwLevel {
  DefaultNsfwLevel
  ExplicitNsfwLevel
  SafeNsfwLevel
  AgeRestrictedNsfwLevel
  UnknownNsfwLevel(Int)
}

Constructors

  • DefaultNsfwLevel
  • ExplicitNsfwLevel
  • SafeNsfwLevel
  • AgeRestrictedNsfwLevel
  • UnknownNsfwLevel(Int)

GUILD_CREATE’s payload is one of these. During an outage all Discord sends is the id.

pub type MaybeAvailableGuild {
  AvailableGuild(Guild)
  OfflineGuild(id.Id(id.Guild))
}

Constructors

pub type MessageNotificationLevel {
  AllMessages
  OnlyMentions
  UnknownMessageNotificationLevel(Int)
}

Constructors

  • AllMessages
  • OnlyMentions
  • UnknownMessageNotificationLevel(Int)
pub type MfaLevel {
  NoMfa
  ElevatedMfa
  UnknownMfaLevel(Int)
}

Constructors

  • NoMfa
  • ElevatedMfa
  • UnknownMfaLevel(Int)
pub type PremiumTier {
  NoTier
  Tier1
  Tier2
  Tier3
  UnknownPremiumTier(Int)
}

Constructors

  • NoTier
  • Tier1
  • Tier2
  • Tier3
  • UnknownPremiumTier(Int)

All six are suppressions, so a set bit HIDES a notice rather than turning one on.

pub type SystemChannelFlag {
  SuppressJoinNotifications
  SuppressPremiumSubscriptions
  SuppressGuildReminderNotifications
  SuppressJoinNotificationReplies
  SuppressRoleSubscriptionPurchaseNotifications
  SuppressRoleSubscriptionPurchaseNotificationReplies
}

Constructors

  • SuppressJoinNotifications
  • SuppressPremiumSubscriptions
  • SuppressGuildReminderNotifications
  • SuppressJoinNotificationReplies
  • SuppressRoleSubscriptionPurchaseNotifications
  • SuppressRoleSubscriptionPurchaseNotificationReplies

GET /users/@me/guilds, which answers with far less than a guild: no owner_id, so decoder() rejects it. owner and permissions are relative to the requesting user and come from nowhere else.

pub type UserGuild {
  UserGuild(
    id: id.Id(id.Guild),
    name: String,
    icon: option.Option(String),
    banner: option.Option(String),
    owner: Bool,
    permissions: option.Option(permissions.Permissions),
    features: List(String),
    counts: option.Option(ApproximateCounts),
  )
}

Constructors

pub type VerificationLevel {
  NoVerification
  LowVerification
  MediumVerification
  HighVerification
  VeryHighVerification
  UnknownVerificationLevel(Int)
}

Constructors

  • NoVerification
  • LowVerification
  • MediumVerification
  • HighVerification
  • VeryHighVerification
  • UnknownVerificationLevel(Int)

Values

pub fn ban_decoder() -> decode.Decoder(Ban)
pub fn decoder() -> decode.Decoder(Guild)
pub fn departure_decoder() -> decode.Decoder(GuildDeparture)

GUILD_DELETE dispatches on the KEY’s PRESENCE, not its value: present is an outage, absent is the bot being kicked, banned or leaving. A present null and a present false are both an outage.

pub fn explicit_content_filter_from_int(
  value: Int,
) -> ExplicitContentFilterLevel
pub fn explicit_content_filter_to_int(
  value: ExplicitContentFilterLevel,
) -> Int
pub const feature_community: String
pub const feature_discoverable: String
pub const feature_enhanced_role_colors: String
pub const feature_invites_disabled: String
pub const feature_partnered: String
pub const feature_role_icons: String
pub const feature_vanity_url: String
pub const feature_verified: String
pub fn has_feature(
  features: List(String),
  feature: String,
) -> Bool
pub fn has_flag(
  bits: flags.Flags(SystemChannelFlag),
  flag: SystemChannelFlag,
) -> Bool
pub fn has_system_channel_flag(
  guild: Guild,
  flag: SystemChannelFlag,
) -> Bool
pub fn maybe_available_decoder() -> decode.Decoder(
  MaybeAvailableGuild,
)

GUILD_CREATE dispatches on the VALUE of unavailable: an available guild may still carry "unavailable": false.

pub fn message_notification_level_from_int(
  value: Int,
) -> MessageNotificationLevel
pub fn message_notification_level_to_int(
  value: MessageNotificationLevel,
) -> Int
pub fn mfa_level_from_int(value: Int) -> MfaLevel
pub fn mfa_level_to_int(value: MfaLevel) -> Int
pub fn nsfw_level_from_int(value: Int) -> GuildNsfwLevel
pub fn nsfw_level_to_int(value: GuildNsfwLevel) -> Int
pub fn nsfw_level_to_json(value: GuildNsfwLevel) -> json.Json
pub fn premium_tier_from_int(value: Int) -> PremiumTier
pub fn premium_tier_to_int(value: PremiumTier) -> Int
pub fn premium_tier_to_json(value: PremiumTier) -> json.Json
pub fn user_guild_decoder() -> decode.Decoder(UserGuild)

GET /users/@me/guilds. A partial: nine keys, and owner_id is not one of them.

pub fn verification_level_from_int(
  value: Int,
) -> VerificationLevel
pub fn verification_level_to_int(value: VerificationLevel) -> Int
pub fn verification_level_to_json(
  value: VerificationLevel,
) -> json.Json
Search Document