Struct Community
zaun_client::Community · Struct
pub struct Community { … }A community this client belongs to (or did: a handle outlives a leave).
Methods
Section titled “Methods”pub fn dms(&self) -> Vec<Channel>This member’s open DMs, from the cache.
fetch_dms
Section titled “fetch_dms”pub fn fetch_dms(&self) -> Result<Vec<Channel>>Reloads the open DMs from the host.
Errors
Section titled “Errors”The host refused or did not answer.
dm_settings
Section titled “dm_settings”pub fn dm_settings(&self) -> Result<DmSettings>This member’s DM setting.
Errors
Section titled “Errors”The host refused or did not answer.
set_dms_from_bots
Section titled “set_dms_from_bots”pub fn set_dms_from_bots(&self, allow: bool) -> Result<DmSettings>Lets bots open DMs with this member (true), or not.
Errors
Section titled “Errors”The host refused or did not answer.
presences
Section titled “presences”pub fn presences(&self) -> Vec<Presence>The presence of every member who is not offline.
set_status_text
Section titled “set_status_text”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
Section titled “Errors”The host’s refusal (PAYLOAD_TOO_LARGE past 128 characters, BAD_REQUEST), or a
connection error.
commands
Section titled “commands”pub fn commands(&self) -> Vec<ApplicationCommand>Every bot command in the community, as last heard (each with its bot_id).
pub fn bots(&self) -> Vec<BotCard>The installed bots’ public cards, as last heard.
fetch_bots
Section titled “fetch_bots”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
Section titled “Errors”The host refused or did not answer.
pub fn bot(&self, bot: BotId) -> Result<BotCard>Asks the host for one bot’s card.
Errors
Section titled “Errors”The host refused (NOT_FOUND) or did not answer.
install_bot
Section titled “install_bot”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
Section titled “Errors”The host refused (not the owner, a bad package, over the ceiling) or did not answer.
update_bot
Section titled “update_bot”pub fn update_bot(&self, bot: BotId, package: AttachmentId) -> Result<BotCard>Owner only: updates a bot to a newer package of the same publisher.
Errors
Section titled “Errors”As install_bot.
grant_bot
Section titled “grant_bot”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
Section titled “Errors”The host refused or did not answer.
enable_bot
Section titled “enable_bot”pub fn enable_bot(&self, bot: BotId) -> Result<BotCard>Owner only: starts a disabled bot.
Errors
Section titled “Errors”The host refused or did not answer.
disable_bot
Section titled “disable_bot”pub fn disable_bot(&self, bot: BotId) -> Result<BotCard>Owner only: stops a bot and hides its commands.
Errors
Section titled “Errors”The host refused or did not answer.
remove_bot
Section titled “remove_bot”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
Section titled “Errors”The host refused or did not answer.
register_bot
Section titled “register_bot”pub fn register_bot(&self, member: &Member, name: Option<&str>) -> Result<BotCard>Owner only: marks member (a client connected over SimpleX) as an external bot.
Errors
Section titled “Errors”The host refused or did not answer.
set_commands
Section titled “set_commands”pub fn set_commands(&self, commands: Vec<ApplicationCommand>) -> Result<Vec<ApplicationCommand>>As a bot: replaces this bot’s whole command list; answers it with the host’s ids.
Errors
Section titled “Errors”The host refused (this member is not a bot, a command breaks the rules).
configure_bot
Section titled “configure_bot”pub fn configure_bot<K, V, impl IntoIterator<Item = (K, Option<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
Section titled “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.
bot_config
Section titled “bot_config”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
Section titled “Errors”As configure_bot.
install_bot_from
Section titled “install_bot_from”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
Section titled “Errors”As install_bot, and BAD_REQUEST for a source that repeats an
attachment or has a blank signature.
update_bot_from
Section titled “update_bot_from”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
Section titled “Errors”As install_bot_from.
pub const fn id(&self) -> CommunityIdIts id.
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).
pub fn name(&self) -> StringIts name, from the descriptor the host’s welcome proved (empty before).
description
Section titled “description”pub fn description(&self) -> Option<String>Its description, from the same descriptor.
is_owner
Section titled “is_owner”pub fn is_owner(&self) -> boolWhether this client owns it.
pub fn me(&self) -> Option<Member>This client as a member of it.
channels
Section titled “channels”pub fn channels(&self) -> Vec<Channel>Its channels and categories this member can see, in order.
channel_by_name
Section titled “channel_by_name”pub fn channel_by_name(&self, name: &str) -> Option<Channel>The first channel named name (names are not unique).
channel
Section titled “channel”pub fn channel(&self, id: ChannelId) -> ChannelThe channel id, known to the cache or not.
pub fn roles(&self) -> Vec<Role>Its roles, highest first.
role_by_name
Section titled “role_by_name”pub fn role_by_name(&self, name: &str) -> Option<Role>The first role named name.
pub fn role(&self, id: RoleId) -> RoleThe role id, known to the cache or not.
members
Section titled “members”pub fn members(&self) -> Vec<Member>The members the cache has heard of; fetch_members loads them
all.
member
Section titled “member”pub fn member(&self, id: MemberId) -> MemberThe member id, known to the cache or not.
fetch_members
Section titled “fetch_members”pub fn fetch_members(&self) -> Result<Vec<Member>>Loads every member into the cache.
Errors
Section titled “Errors”The host refused or did not answer.
create_channel
Section titled “create_channel”pub fn create_channel(&self, name: &str, kind: ChannelKind) -> Result<Channel>Makes a channel of kind named name.
Errors
Section titled “Errors”The host refused (no MANAGE_CHANNELS) or did not answer.
create_channel_in
Section titled “create_channel_in”pub fn create_channel_in(&self, parent: &Channel, name: &str, kind: ChannelKind) -> Result<Channel>Makes a channel of kind named name inside the category parent.
Errors
Section titled “Errors”As create_channel.
create_role
Section titled “create_role”pub fn create_role(&self, name: &str, permissions: Permissions) -> Result<Role>Makes a role named name with permissions.
Errors
Section titled “Errors”The host refused (no MANAGE_ROLES, or permissions this member lacks) or did not
answer.
create_invite
Section titled “create_invite”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
Section titled “Errors”The host refused or did not answer.
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
Section titled “Errors”The host refused or did not answer.
hand_off
Section titled “hand_off”pub fn hand_off(&self, host_address: &str, host_key: PublicKey) -> Result<HandOff>As the owner, hands the community to the host at host_address whose key is
host_key; see HandOff.
Errors
Section titled “Errors”This client does not hold the root key, the host refused, or no answer came.
follow
Section titled “follow”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
Section titled “Errors”The new host refused this member, or a timeout.
voice_channels
Section titled “voice_channels”pub fn voice_channels(&self) -> Vec<Channel>This member’s voice channels.
Trait implementations
Section titled “Trait implementations”Clone, Debug, Display, PartialEq