Skip to main content

Channel

Struct Channel 

Source
pub struct Channel { /* private fields */ }
Expand description

A channel or category of a community.

Implementations§

Source§

impl Channel

Source

pub fn is_dm(&self) -> bool

Whether it is a direct message, not a community channel.

Source

pub fn recipient(&self) -> Option<Member>

The other participant of a DM; None for a community channel.

Source

pub fn close_dm(&self) -> Result<()>

Closes a DM for this member.

§Errors

NOT_FOUND or no answer.

Source§

impl Channel

Source

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.

Source

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).

Source

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.

Source

pub fn typing_mode(&self) -> TypingMode

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

Source§

impl Channel

Source

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.

Source

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.

Source

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

Source

pub const fn id(&self) -> ChannelId

Its id.

Source

pub const fn community(&self) -> &Community

The community it belongs to.

Source

pub fn data(&self) -> Option<ChannelData>

The cache’s copy, or None when the cache does not have it (any more).

Source

pub fn name(&self) -> String

Its name (empty when the cache does not have it).

Source

pub fn kind(&self) -> ChannelKind

Text when the cache does not have it.

Source

pub fn topic(&self) -> Option<String>

Its topic.

Source

pub fn parent(&self) -> Option<Self>

The category it is in.

Source

pub fn is_voice(&self) -> bool

Whether it is a voice (or stage) channel.

Source

pub fn is_category(&self) -> bool

Whether it is a category.

Source

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.

Source

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.

Source

pub fn send_files( &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

A file the host would not take (too large, a file server it does not use), a failed upload, or as send.

Source

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.

Source

pub fn delete(&self) -> Result<()>

Deletes the channel or category.

§Errors

The host refused or did not answer.

Source

pub fn participants(&self) -> Vec<VoiceParticipant>

Who is in this voice channel now (no key material).

Source

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.

Source

pub fn join_with(&self, options: VoiceOptions) -> Result<VoiceSession>

join with options (a direct path, joining muted or deafened).

§Errors

As join.

Source§

impl Channel

Source

pub fn message(&self, id: MessageId) -> PartialMessage

The message id in this channel, to act on without fetching it.

Trait Implementations§

Source§

impl Clone for Channel

Source§

fn clone(&self) -> Channel

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 Channel

Source§

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

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

impl Display for Channel

Source§

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

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

impl PartialEq for Channel

Source§

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

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

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

Inequality operator !=. Read more

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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