pub struct Community { /* private fields */ }Expand description
A community this client belongs to (or did: a handle outlives a leave).
Implementations§
Source§impl Community
impl Community
Sourcepub fn dm_settings(&self) -> Result<DmSettings>
pub fn dm_settings(&self) -> Result<DmSettings>
Sourcepub fn set_dms_from_bots(&self, allow: bool) -> Result<DmSettings>
pub fn set_dms_from_bots(&self, allow: bool) -> Result<DmSettings>
Source§impl Community
impl Community
Sourcepub fn set_status_text(
&self,
text: Option<&str>,
emoji: Option<&str>,
expires_at: Option<u64>,
) -> Result<MemberData>
pub fn set_status_text( &self, text: Option<&str>, emoji: Option<&str>, expires_at: Option<u64>, ) -> Result<MemberData>
Sets this member’s custom status here (text, emoji, and when the host clears it, ms);
None for both text and emoji clears it. Everyone else gets a member update.
§Errors
The host’s refusal (PAYLOAD_TOO_LARGE past 128 characters, BAD_REQUEST), or a
connection error.
Source§impl Community
impl Community
Sourcepub fn commands(&self) -> Vec<ApplicationCommand>
pub fn commands(&self) -> Vec<ApplicationCommand>
Every bot command in the community, as last heard (each with its bot_id).
Sourcepub fn fetch_bots(&self) -> Result<Vec<BotCard>>
pub fn fetch_bots(&self) -> Result<Vec<BotCard>>
Asks the host for every bot’s card (owners also get each bot’s full request).
§Errors
The host refused or did not answer.
Sourcepub fn install_bot(
&self,
package: AttachmentId,
grants: Option<GrantChoice>,
role_position: Option<u32>,
) -> Result<BotCard>
pub fn install_bot( &self, package: AttachmentId, grants: Option<GrantChoice>, role_position: Option<u32>, ) -> Result<BotCard>
Owner only: installs the .zbot package uploaded as package (an attachment not on
a message). grants absent: everything the manifest asks for, within the host’s ceiling.
§Errors
The host refused (not the owner, a bad package, over the ceiling) or did not answer.
Sourcepub fn update_bot(&self, bot: BotId, package: AttachmentId) -> Result<BotCard>
pub fn update_bot(&self, bot: BotId, package: AttachmentId) -> Result<BotCard>
Sourcepub fn grant_bot(
&self,
bot: BotId,
permissions: Option<Permissions>,
capabilities: Option<Capabilities>,
) -> Result<BotCard>
pub fn grant_bot( &self, bot: BotId, permissions: Option<Permissions>, capabilities: Option<Capabilities>, ) -> Result<BotCard>
Owner only: replaces a bot’s grants (approves a waiting update when it covers it).
§Errors
The host refused or did not answer.
Sourcepub fn enable_bot(&self, bot: BotId) -> Result<BotCard>
pub fn enable_bot(&self, bot: BotId) -> Result<BotCard>
Sourcepub fn disable_bot(&self, bot: BotId) -> Result<BotCard>
pub fn disable_bot(&self, bot: BotId) -> Result<BotCard>
Sourcepub fn remove_bot(&self, bot: BotId, keep_data: bool) -> Result<()>
pub fn remove_bot(&self, bot: BotId, keep_data: bool) -> Result<()>
Owner only: removes a bot, its role and commands (and its data unless keep_data).
§Errors
The host refused or did not answer.
Source§impl Community
impl Community
Sourcepub fn configure_bot<K, V>(
&self,
bot: BotId,
values: impl IntoIterator<Item = (K, Option<V>)>,
) -> Result<BTreeMap<String, String>>
pub fn configure_bot<K, V>( &self, bot: BotId, values: impl IntoIterator<Item = (K, Option<V>)>, ) -> Result<BTreeMap<String, String>>
Owner only: sets (Some) or clears (None, back to the default) the values of the
settings bot’s manifest declares (its card’s config), and answers every value the
owner has set, a secret one as "••••" (MASKED).
The bot gets them at once. Keys are [a-z][a-z0-9_]{0,63}, values ≤ 4 KiB, ≤ 32 of
each.
§Errors
A malformed key or value (Error::Protocol), or the host
refused: FORBIDDEN (not the owner), NOT_FOUND (no such bot), BAD_REQUEST with
field config.<key> (a key the manifest does not declare). Needs zaun-host 0.4.0.
Sourcepub fn bot_config(&self, bot: BotId) -> Result<BTreeMap<String, String>>
pub fn bot_config(&self, bot: BotId) -> Result<BTreeMap<String, String>>
Owner only: the values set for bot’s settings, a secret one as "••••"; a key
not here uses its card’s default.
§Errors
As configure_bot.
Source§impl Community
impl Community
Sourcepub fn install_bot_from(
&self,
package: AttachmentId,
grants: Option<GrantChoice>,
role_position: Option<u32>,
source: InstallSource,
) -> Result<BotCard>
pub fn install_bot_from( &self, package: AttachmentId, grants: Option<GrantChoice>, role_position: Option<u32>, source: InstallSource, ) -> Result<BotCard>
Owner only: install_bot with the registry source the package
was verified against: the uploaded catalog.json, its signature and, for a version not
in the catalog’s latest, the uploaded history file. The host checks the source
offline against its own registry keys; one that does not verify installs as direct.
§Errors
As install_bot, and BAD_REQUEST for a source that repeats an
attachment or has a blank signature.
Sourcepub fn update_bot_from(
&self,
bot: BotId,
package: AttachmentId,
source: InstallSource,
) -> Result<BotCard>
pub fn update_bot_from( &self, bot: BotId, package: AttachmentId, source: InstallSource, ) -> Result<BotCard>
Owner only: update_bot with the registry source the new package
was verified against, as for install_bot_from.
§Errors
As install_bot_from.
Source§impl Community
impl Community
Sourcepub fn data(&self) -> Option<CommunityData>
pub fn data(&self) -> Option<CommunityData>
A copy of the cache: the whole community as plain data, or None when this client
does not belong to it (any more).
Sourcepub fn name(&self) -> String
pub fn name(&self) -> String
Its name, from the descriptor the host’s welcome proved (empty before).
Sourcepub fn description(&self) -> Option<String>
pub fn description(&self) -> Option<String>
Its description, from the same descriptor.
Sourcepub fn channels(&self) -> Vec<Channel>
pub fn channels(&self) -> Vec<Channel>
Its channels and categories this member can see, in order.
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 (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 members(&self) -> Vec<Member>
pub fn members(&self) -> Vec<Member>
The members the cache has heard of; fetch_members loads them
all.
Sourcepub fn fetch_members(&self) -> Result<Vec<Member>>
pub fn fetch_members(&self) -> Result<Vec<Member>>
Sourcepub fn create_channel(&self, name: &str, kind: ChannelKind) -> Result<Channel>
pub fn create_channel(&self, name: &str, kind: ChannelKind) -> Result<Channel>
Makes a channel of kind named name.
§Errors
The host refused (no MANAGE_CHANNELS) or did not answer.
Sourcepub fn create_channel_in(
&self,
parent: &Channel,
name: &str,
kind: ChannelKind,
) -> Result<Channel>
pub fn create_channel_in( &self, parent: &Channel, name: &str, kind: ChannelKind, ) -> Result<Channel>
Sourcepub fn create_role(&self, name: &str, permissions: Permissions) -> Result<Role>
pub fn create_role(&self, name: &str, permissions: Permissions) -> Result<Role>
Makes a role named name with permissions.
§Errors
The host refused (no MANAGE_ROLES, or permissions this member lacks) or did not
answer.
Sourcepub fn create_invite(
&self,
max_uses: u32,
expires_in: Option<Duration>,
) -> Result<String>
pub fn create_invite( &self, max_uses: u32, expires_in: Option<Duration>, ) -> Result<String>
Makes an invitation link for max_uses joins (0: no limit), expiring after
expires_in if given. The link is a secret: give it only to who should join.
§Errors
The host refused or did not answer.
Sourcepub fn leave(&self) -> Result<()>
pub fn leave(&self) -> Result<()>
Leaves the community (the owner cannot). Once the host accepts, it is forgotten here:
its state and member key leave the store, Event::CommunityDelete
follows with RemovalReason::Left, and a later Client::join
of it starts afresh.
§Errors
The host refused or did not answer.
Sourcepub fn follow(&self, host_address: &str, host_key: PublicKey) -> Result<HostId>
pub fn follow(&self, host_address: &str, host_key: PublicKey) -> Result<HostId>
Follows the community to the host the owner named, when no descriptor update arrived.
§Errors
The new host refused this member, or a timeout.
Sourcepub fn voice_channels(&self) -> Vec<Channel>
pub fn voice_channels(&self) -> Vec<Channel>
This member’s voice channels.