Skip to content

Struct CommunityData

zaun_client::CommunityData · Struct

pub struct CommunityData { … }

A community as this client last heard of it. Cheap to clone; a clone does not update.

Every map is bounded by the community itself: entries leave when the host reports the channel, role or member gone. members holds the members this client has heard of (events, Community::fetch_members), not always all.

The community.

This client’s member id in it.

Whether this client is the owner.

The host’s snapshot has loaded at least once (Event::Ready was said).

The community’s name, from its descriptor as the host’s welcome proved it (empty until then).

Its description, from the same descriptor.

The host-managed profile, once the snapshot has it.

Channels and categories this member can see.

DM: this member’s open direct messages with bots, by channel. Entries leave when the DM is closed here or the community is.

Roles, @everyone (RoleId::EVERYONE) included.

Members heard of, this client included once the snapshot arrived.

What the host takes as attachments (its largest file, the file servers it downloads from), from its last welcome; None before one, or when the host did not say.

The capabilities this client and the host both support (frag, embeds, …), from the host’s last welcome; empty before one. Replaced at each welcome, so it never grows.

commands: BTreeMap<CommandId, ApplicationCommand>

Section titled “commands: BTreeMap<CommandId, ApplicationCommand>”

The bots’ application commands, each with its bot_id. A bot’s whole list is replaced by command.updated and dropped with the bot, so it never outgrows the bots.

Installed bots’ public cards; an entry leaves with bot.removed.

Typing: who else is typing per channel (CommunityData::typing_in). One entry per channel, replaced by each signal.typing, gone with the channel.

presences: BTreeMap<MemberId, PresenceSignal>

Section titled “presences: BTreeMap<MemberId, PresenceSignal>”

Presence: every member not offline, as others see them (presence.list, then each signal.presence); see CommunityData::presence_of.

pub fn supports(&self, capability: &str) -> bool

Whether the host’s last welcome listed capability.

pub fn channel_by_name(&self, name: &str) -> Option<&Channel>

The first channel named name (channel names are not unique).

pub fn role_by_name(&self, name: &str) -> Option<&Role>

The first role named name.

pub fn ordered_channels(&self) -> Vec<&Channel>

Channels in display order: by position, categories’ children after them.

pub fn permissions(&self, member: &MemberId, channel: Option<&ChannelId>, now_ms: u64) -> Option<Resolved>

What member may do in channel (or community-wide with None) at now_ms, or None when the member or the channel is not in the cache.

pub fn can(&self, member: &MemberId, channel: Option<&ChannelId>, bits: Permissions, now_ms: u64) -> bool

Whether member has every bit of bits in channel at now_ms (see permissions); false when the cache does not know.

pub fn can_use(&self, member: &MemberId, channel: &ChannelId, command: &ApplicationCommand, now_ms: u64) -> bool

Whether member may use bot command command in channel: VIEW_CHANNEL and USE_APPLICATION_COMMANDS there, plus the command’s default_member_permissions ("0": the owner only). As the rest of this view, it can show more than the host allows.

pub fn presence_of(&self, member: MemberId) -> Presence

member’s presence (offline when the cache has none).

pub fn typing_in(&self, channel: &ChannelId, now_ms: u64) -> Option<&TypingNow>

Who else is typing in channel at now_ms, if anyone.

pub fn typing_mode(&self, channel: &ChannelId) -> TypingMode

The channel’s typing setting (named when the cache does not have the channel).

Clone, Debug, PartialEq, Serialize, StructuralPartialEq

Full rustdoc page