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.
Fields
Section titled “Fields”id: CommunityId
Section titled “id: CommunityId”The community.
me: MemberId
Section titled “me: MemberId”This client’s member id in it.
is_owner: bool
Section titled “is_owner: bool”Whether this client is the owner.
loaded: bool
Section titled “loaded: bool”The host’s snapshot has loaded at least once (Event::Ready
was said).
name: String
Section titled “name: String”The community’s name, from its descriptor as the host’s welcome proved it (empty until then).
description: Option<String>
Section titled “description: Option<String>”Its description, from the same descriptor.
profile: Option<CommunityProfile>
Section titled “profile: Option<CommunityProfile>”The host-managed profile, once the snapshot has it.
channels: BTreeMap<ChannelId, Channel>
Section titled “channels: BTreeMap<ChannelId, Channel>”Channels and categories this member can see.
dms: BTreeMap<ChannelId, DmChannel>
Section titled “dms: BTreeMap<ChannelId, DmChannel>”DM: this member’s open direct messages with bots, by channel. Entries leave when the DM is closed here or the community is.
roles: BTreeMap<RoleId, Role>
Section titled “roles: BTreeMap<RoleId, Role>”Roles, @everyone (RoleId::EVERYONE) included.
members: BTreeMap<MemberId, Member>
Section titled “members: BTreeMap<MemberId, Member>”Members heard of, this client included once the snapshot arrived.
attachments: Option<HostAttachments>
Section titled “attachments: Option<HostAttachments>”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.
capabilities: Vec<String>
Section titled “capabilities: Vec<String>”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.
bots: BTreeMap<BotId, BotCard>
Section titled “bots: BTreeMap<BotId, BotCard>”Installed bots’ public cards; an entry leaves with bot.removed.
typing: BTreeMap<ChannelId, TypingSeen>
Section titled “typing: BTreeMap<ChannelId, TypingSeen>”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.
Methods
Section titled “Methods”supports
Section titled “supports”pub fn supports(&self, capability: &str) -> boolWhether the host’s last welcome listed capability.
channel_by_name
Section titled “channel_by_name”pub fn channel_by_name(&self, name: &str) -> Option<&Channel>The first channel named name (channel names are not unique).
role_by_name
Section titled “role_by_name”pub fn role_by_name(&self, name: &str) -> Option<&Role>The first role named name.
ordered_channels
Section titled “ordered_channels”pub fn ordered_channels(&self) -> Vec<&Channel>Channels in display order: by position, categories’ children after them.
permissions
Section titled “permissions”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) -> boolWhether member has every bit of bits in channel at now_ms (see
permissions); false when the cache does not know.
can_use
Section titled “can_use”pub fn can_use(&self, member: &MemberId, channel: &ChannelId, command: &ApplicationCommand, now_ms: u64) -> boolWhether 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.
presence_of
Section titled “presence_of”pub fn presence_of(&self, member: MemberId) -> Presencemember’s presence (offline when the cache has none).
typing_in
Section titled “typing_in”pub fn typing_in(&self, channel: &ChannelId, now_ms: u64) -> Option<&TypingNow>Who else is typing in channel at now_ms, if anyone.
typing_mode
Section titled “typing_mode”pub fn typing_mode(&self, channel: &ChannelId) -> TypingModeThe channel’s typing setting (named when the cache does not have the channel).
Trait implementations
Section titled “Trait implementations”Clone, Debug, PartialEq, Serialize, StructuralPartialEq