Skip to main content

CommunityData

Struct CommunityData 

Source
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: CommunityId

The community.

§me: MemberId

This client’s member id in it.

§is_owner: bool

Whether this client is the owner.

§loaded: bool

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

§name: String

The 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

Source

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

Whether the host’s last welcome listed capability.

Source

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

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

Source

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

The first role named name.

Source

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

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

Source§

impl CommunityData

Source

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

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.

Source§

impl CommunityData

Source

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

Source

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

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

Source§

impl CommunityData

Source

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

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

Source

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

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

Trait Implementations§

Source§

impl Clone for CommunityData

Source§

fn clone(&self) -> CommunityData

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CommunityData

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for CommunityData

Source§

fn eq(&self, other: &CommunityData) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for CommunityData

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for CommunityData

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T> CryptoSafe for T
where T: Send + Sync + Debug,

§

impl<T> CryptoSafe for T

Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more