Struct Channel
zaun_client::Channel · Struct
pub struct Channel { … }A channel or category of a community.
Methods
Section titled “Methods”pub fn is_dm(&self) -> boolWhether it is a direct message, not a community channel.
recipient
Section titled “recipient”pub fn recipient(&self) -> Option<Member>The other participant of a DM; None for a community channel.
close_dm
Section titled “close_dm”pub fn close_dm(&self) -> Result<()>Closes a DM for this member.
Errors
Section titled “Errors”NOT_FOUND or no answer.
start_typing
Section titled “start_typing”pub fn start_typing(&self) -> Result<bool>Tells the host this member is typing here; call it while the user types (the host
forwards at most one signal per member per channel per 3 s). Returns false without
sending anything in a channel whose typing is off.
Errors
Section titled “Errors”Error::Closed when the client stopped.
typing
Section titled “typing”pub fn typing(&self) -> Option<TypingNow>Who else is typing here now: members by id in a named channel, only how many in an
anonymous one; None when nobody is (or the channel’s typing is off).
set_typing_mode
Section titled “set_typing_mode”pub fn set_typing_mode(&self, mode: TypingMode) -> Result<()>Sets who sees typing here (channel.update, needs MANAGE_CHANNELS): Named,
Anonymous or Off. The cache follows with the host’s channel.updated.
Errors
Section titled “Errors”Error::Refused (FORBIDDEN without the permission), or no
answer.
typing_mode
Section titled “typing_mode”pub fn typing_mode(&self) -> TypingModeThe channel’s typing setting (named when the cache does not have it).
invoke_command
Section titled “invoke_command”pub fn invoke_command(&self, command: CommandId, options: Vec<OptionValue>, target: Option<String>) -> Result<InteractionId>Runs a bot command here. target is the member (user command) or message (message
command) acted on, base64url. The bot’s answer arrives as an event.
Errors
Section titled “Errors”The host refused (no USE_APPLICATION_COMMANDS, bad options) or did not answer.
autocomplete
Section titled “autocomplete”pub fn autocomplete(&self, command: CommandId, options: Vec<OptionValue>) -> Result<InteractionId>Asks the bot for suggestions for the option marked focused; they arrive as
Event::Autocomplete.
Errors
Section titled “Errors”As invoke_command.
submit_modal
Section titled “submit_modal”pub fn submit_modal(&self, modal: InteractionId, custom_id: &str, components: Vec<SubmittedInput>) -> Result<InteractionId>Submits a modal a bot opened (Event::ModalOpen): modal
is the interaction that opened it.
Errors
Section titled “Errors”The host refused (a required field missing, too late, submitted already).
pub const fn id(&self) -> ChannelIdIts id.
community
Section titled “community”pub const fn community(&self) -> &CommunityThe community it belongs to.
pub fn data(&self) -> Option<ChannelData>The cache’s copy, or None when the cache does not have it (any more).
pub fn name(&self) -> StringIts name (empty when the cache does not have it).
pub fn kind(&self) -> ChannelKindText when the cache does not have it.
pub fn topic(&self) -> Option<String>Its topic.
parent
Section titled “parent”pub fn parent(&self) -> Option<Self>The category it is in.
is_voice
Section titled “is_voice”pub fn is_voice(&self) -> boolWhether it is a voice (or stage) channel.
is_category
Section titled “is_category”pub fn is_category(&self) -> boolWhether it is a category.
pub fn send<impl Into<MessageOptions>>(&self, options: impl Into<MessageOptions>) -> Result<Message>Posts a message: text (channel.send("hi")), or MessageOptions with embeds,
files and the message it answers. An embed’s pictures and the files are uploaded
first, each once, over this member’s post-quantum connection to the host.
Errors
Section titled “Errors”A broken embed or more than 10 files and pictures (Error::Protocol, before
anything is uploaded); embeds to a host that does not keep them
(Error::Unsupported); a failed upload; or the host refused (no SEND_MESSAGES,
EMBED_LINKS or ATTACH_FILES, slowmode, too long) or did not answer.
send_pending
Section titled “send_pending”pub fn send_pending<impl Into<MessageOptions>>(&self, options: impl Into<MessageOptions>) -> Result<PendingMessage>Posts like send but returns at once with the message as it will look,
so it can be shown before the host answers (it takes a relay round trip or two). The
outcome comes as Event::MessageSent or
Event::MessageSendFailed with the same
pending number. Text posts keep their order; a post
with files uploads them first and may land after text sent later.
Errors
Section titled “Errors”What send refuses before anything leaves (a broken embed, too many
files, a host without embeds), not yet a member, or the client stopped.
send_files
Section titled “send_files”pub fn send_files<impl AsRef<Path>>(&self, content: &str, paths: &[impl AsRef<Path>]) -> Result<Message>Posts content with the files at paths attached (each uploaded first, over this
member’s post-quantum connection to the host).
Errors
Section titled “Errors”A file the host would not take (too large, a file server it does not use), a failed
upload, or as send.
messages
Section titled “messages”pub fn messages(&self, before: Option<u64>, limit: u32) -> Result<Vec<Message>>Up to limit messages before sequence before (the newest without it), oldest first.
Errors
Section titled “Errors”The host refused (no READ_MESSAGE_HISTORY) or did not answer.
delete
Section titled “delete”pub fn delete(&self) -> Result<()>Deletes the channel or category.
Errors
Section titled “Errors”The host refused or did not answer.
participants
Section titled “participants”pub fn participants(&self) -> Vec<VoiceParticipant>Who is in this voice channel now (no key material).
pub fn join(&self) -> Result<VoiceSession>Joins this voice channel: relayed through the host’s TURN server, every frame sealed
end to end. See VoiceSession.
Errors
Section titled “Errors”Not a voice channel, already in voice in this community, a host media policy this client does not accept, no relay to be had, or the host refused.
join_with
Section titled “join_with”pub fn join_with(&self, options: VoiceOptions) -> Result<VoiceSession>join with options (a direct path, joining muted or deafened).
Errors
Section titled “Errors”As join.
message
Section titled “message”pub fn message(&self, id: MessageId) -> PartialMessageThe message id in this channel, to act on without fetching it.
Trait implementations
Section titled “Trait implementations”Clone, Debug, Display, PartialEq