pub struct Channel { /* private fields */ }Expand description
A channel or category of a community.
Implementations§
Source§impl Channel
impl Channel
Source§impl Channel
impl Channel
Sourcepub fn start_typing(&self) -> Result<bool>
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
Error::Closed when the client stopped.
Sourcepub fn typing(&self) -> Option<TypingNow>
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).
Sourcepub fn set_typing_mode(&self, mode: TypingMode) -> Result<()>
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
Error::Refused (FORBIDDEN without the permission), or no
answer.
Sourcepub fn typing_mode(&self) -> TypingMode
pub fn typing_mode(&self) -> TypingMode
The channel’s typing setting (named when the cache does not have it).
Source§impl Channel
impl Channel
Sourcepub fn invoke_command(
&self,
command: CommandId,
options: Vec<OptionValue>,
target: Option<String>,
) -> Result<InteractionId>
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
The host refused (no USE_APPLICATION_COMMANDS, bad options) or did not answer.
Sourcepub fn autocomplete(
&self,
command: CommandId,
options: Vec<OptionValue>,
) -> Result<InteractionId>
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
As invoke_command.
Sourcepub fn submit_modal(
&self,
modal: InteractionId,
custom_id: &str,
components: Vec<SubmittedInput>,
) -> Result<InteractionId>
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
The host refused (a required field missing, too late, submitted already).
Source§impl Channel
impl Channel
Sourcepub fn data(&self) -> Option<ChannelData>
pub fn data(&self) -> Option<ChannelData>
The cache’s copy, or None when the cache does not have it (any more).
Sourcepub fn is_category(&self) -> bool
pub fn is_category(&self) -> bool
Whether it is a category.
Sourcepub fn send(&self, options: impl Into<MessageOptions>) -> Result<Message>
pub fn send(&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
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.
Sourcepub fn send_pending(
&self,
options: impl Into<MessageOptions>,
) -> Result<PendingMessage>
pub fn send_pending( &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
What send refuses before anything leaves (a broken embed, too many
files, a host without embeds), not yet a member, or the client stopped.
Sourcepub fn messages(&self, before: Option<u64>, limit: u32) -> Result<Vec<Message>>
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
The host refused (no READ_MESSAGE_HISTORY) or did not answer.
Sourcepub fn participants(&self) -> Vec<VoiceParticipant>
pub fn participants(&self) -> Vec<VoiceParticipant>
Who is in this voice channel now (no key material).
Sourcepub fn join(&self) -> Result<VoiceSession>
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
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.