pub struct CommunityData {Show 17 fields
pub id: CommunityId,
pub me: MemberId,
pub is_owner: bool,
pub loaded: bool,
pub name: String,
pub description: Option<String>,
pub profile: Option<CommunityProfile>,
pub channels: BTreeMap<ChannelId, Channel>,
pub dms: BTreeMap<ChannelId, DmChannel>,
pub roles: BTreeMap<RoleId, Role>,
pub members: BTreeMap<MemberId, Member>,
pub attachments: Option<HostAttachments>,
pub capabilities: Vec<String>,
pub commands: BTreeMap<CommandId, ApplicationCommand>,
pub bots: BTreeMap<BotId, BotCard>,
pub typing: BTreeMap<ChannelId, TypingSeen>,
pub presences: BTreeMap<MemberId, PresenceSignal>,
}Expand description
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§
§id: CommunityIdThe community.
me: MemberIdThis client’s member id in it.
is_owner: boolWhether this client is the owner.
loaded: boolThe host’s snapshot has loaded at least once (Event::Ready
was said).
name: StringThe community’s name, from its descriptor as the host’s welcome proved it (empty until then).
description: Option<String>Its description, from the same descriptor.
profile: Option<CommunityProfile>The host-managed profile, once the snapshot has it.
channels: BTreeMap<ChannelId, Channel>Channels and categories this member can see.
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>Roles, @everyone (RoleId::EVERYONE) included.
members: BTreeMap<MemberId, Member>Members heard of, this client included once the snapshot arrived.
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>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>The bots’ application commands (§8.14), 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>Installed bots’ public cards (§8.13); an entry leaves with bot.removed.
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>Presence: every member not offline, as others see them (presence.list, then each
signal.presence); see CommunityData::presence_of.
Implementations§
Source§impl CommunityData
impl CommunityData
Sourcepub fn supports(&self, capability: &str) -> bool
pub fn supports(&self, capability: &str) -> bool
Whether the host’s last welcome listed capability.
Sourcepub fn channel_by_name(&self, name: &str) -> Option<&Channel>
pub fn channel_by_name(&self, name: &str) -> Option<&Channel>
The first channel named name (channel names are not unique).
Sourcepub fn role_by_name(&self, name: &str) -> Option<&Role>
pub fn role_by_name(&self, name: &str) -> Option<&Role>
The first role named name.
Sourcepub fn ordered_channels(&self) -> Vec<&Channel>
pub fn ordered_channels(&self) -> Vec<&Channel>
Channels in display order: by position, categories’ children after them.
Source§impl CommunityData
impl CommunityData
Sourcepub fn permissions(
&self,
member: &MemberId,
channel: Option<&ChannelId>,
now_ms: u64,
) -> Option<Resolved>
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.
Source§impl CommunityData
impl CommunityData
Sourcepub fn can_use(
&self,
member: &MemberId,
channel: &ChannelId,
command: &ApplicationCommand,
now_ms: u64,
) -> bool
pub fn can_use( &self, member: &MemberId, channel: &ChannelId, command: &ApplicationCommand, now_ms: u64, ) -> bool
Whether member may use bot command command in channel (§8.14): 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.
Source§impl CommunityData
impl CommunityData
Sourcepub fn presence_of(&self, member: MemberId) -> Presence
pub fn presence_of(&self, member: MemberId) -> Presence
member’s presence (offline when the cache has none).
Source§impl CommunityData
impl CommunityData
Trait Implementations§
Source§impl Clone for CommunityData
impl Clone for CommunityData
Source§fn clone(&self) -> CommunityData
fn clone(&self) -> CommunityData
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more