Skip to main content

CollectorBuilder

Struct CollectorBuilder 

Source
pub struct CollectorBuilder<T: Collectable, M = Stream> { /* private fields */ }
Expand description

Configures a collector; made by the extension methods (component_collector, await_messages, …) and the Context methods taking IDs.

T is what the collector yields; M is what the builder makes (mode::Stream: build a Collector; mode::First and mode::All: .await the builder). The collector is registered when it is built or awaited, not before.

discord.js counterpart: the collector options (CollectorOptions, MessageCollectorOptions, ReactionCollectorOptions, InteractionCollectorOptions).

Implementations§

Source§

impl<T: Collectable, M> CollectorBuilder<T, M>

Source

pub const fn time(self, time: Duration) -> Self

Ends the collector after time (discord.js: time).

Source

pub const fn idle(self, idle: Duration) -> Self

Ends the collector when nothing was collected for idle (discord.js: idle).

Source

pub const fn max(self, max: usize) -> Self

Ends the collector after collecting max items (discord.js: max). For reactions with dispose, a removal gives its place back, as in discord.js.

Source

pub const fn max_processed(self, max: usize) -> Self

Ends the collector after max items arrived, whether the filter accepted them or not (discord.js: maxProcessed).

Source

pub fn filter(self, filter: impl FnMut(&T) -> bool + Send + 'static) -> Self

Collects only the items filter accepts (discord.js: filter). Rejected items still count for max_processed. The filter runs where the collector is polled, never on the shard.

Source§

impl<M> CollectorBuilder<ComponentInteraction, M>

Source

pub const fn component_type(self, kind: ComponentType) -> Self

Collects only components of this type (discord.js: componentType); others are ignored, not even processed.

Source

pub const fn max_users(self, max: usize) -> Self

Ends the collector when max different users were collected (discord.js: maxUsers).

Source§

impl<M> CollectorBuilder<ReactionEvent, M>

Source

pub const fn dispose(self, dispose: bool) -> Self

Also yields the removal of collected reactions (ReactionEvent::Removed, ReactionEvent::RemovedAll; discord.js: dispose).

Source

pub const fn max_users(self, max: usize) -> Self

Ends the collector when max different users were collected (discord.js: maxUsers).

Source

pub const fn max_emojis(self, max: usize) -> Self

Ends the collector when max different emojis were collected (discord.js: maxEmojis).

Source§

impl<T: Collectable> CollectorBuilder<T, Stream>

Source

pub fn build(self) -> Collector<T>

Registers the collector: it collects from now until it ends.

discord.js counterpart: createMessageCollector, createReactionCollector, createMessageComponentCollector.

Trait Implementations§

Source§

impl<T: Collectable, M> Debug for CollectorBuilder<T, M>

Source§

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

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

impl<T: Collectable> IntoFuture for CollectorBuilder<T, First>

Source§

type Output = Result<T, CollectorError>

The output that the future will produce on completion.
Source§

type IntoFuture = AwaitFirst<T>

Which kind of future are we turning this into?
Source§

fn into_future(self) -> AwaitFirst<T> ⓘ

Creates a future from a value. Read more
Source§

impl IntoFuture for CollectorBuilder<Arc<MessageCreate>, All>

Source§

type Output = Collected<Id<MessageMarker>, Arc<MessageCreate>>

The output that the future will produce on completion.
Source§

type IntoFuture = AwaitAll<Arc<MessageCreate>, Id<MessageMarker>, Arc<MessageCreate>>

Which kind of future are we turning this into?
Source§

fn into_future(self) -> Self::IntoFuture

Creates a future from a value. Read more
Source§

impl IntoFuture for CollectorBuilder<ReactionEvent, All>

Source§

type Output = Collected<String, CollectedReaction>

The output that the future will produce on completion.
Source§

type IntoFuture = AwaitAll<ReactionEvent, String, CollectedReaction>

Which kind of future are we turning this into?
Source§

fn into_future(self) -> Self::IntoFuture

Creates a future from a value. Read more

Auto Trait Implementations§

§

impl<T, M = Stream> !RefUnwindSafe for CollectorBuilder<T, M>

§

impl<T, M = Stream> !Sync for CollectorBuilder<T, M>

§

impl<T, M = Stream> !UnwindSafe for CollectorBuilder<T, M>

§

impl<T, M> Freeze for CollectorBuilder<T, M>

§

impl<T, M> Send for CollectorBuilder<T, M>

§

impl<T, M> Unpin for CollectorBuilder<T, M>

§

impl<T, M> UnsafeUnpin for CollectorBuilder<T, M>

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,

§

impl<T> Classify for T

§

type Classified = T

§

fn classify(self) -> T

§

impl<T> Declassify for T

§

type Declassified = T

§

fn declassify(self) -> T

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.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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

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