Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 7 additions & 33 deletions src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,31 +202,12 @@ impl ClientBuilder {

/// Sets the voice gateway handler to be used. It will receive voice events sent over the
/// gateway and then consider - based on its settings - whether to dispatch a command.
///
/// *Info*: If a reference to the voice_manager is required for manual dispatch, use the
/// [`Self::voice_manager_arc`]-method instead.
#[cfg(feature = "voice")]
pub fn voice_manager<V>(mut self, voice_manager: V) -> Self
pub fn voice_manager_arc<V>(mut self, voice_manager: impl Into<Arc<V>>) -> Self
where
V: VoiceGatewayManager + 'static,
{
self.voice_manager = Some(Arc::new(voice_manager));

self
}

/// This method allows to pass an [`Arc`]'ed `voice_manager` - this step is done for you in the
/// [`voice_manager`]-method, if you don't need the extra control. You can provide a clone and
/// keep the original to manually dispatch.
///
/// [`voice_manager`]: Self::voice_manager
#[cfg(feature = "voice")]
pub fn voice_manager_arc(
mut self,
voice_manager: Arc<dyn VoiceGatewayManager + 'static>,
) -> Self {
self.voice_manager = Some(voice_manager);

self.voice_manager = Some(voice_manager.into());
self
}

Expand Down Expand Up @@ -268,18 +249,11 @@ impl ClientBuilder {
}

/// Adds an event handler with multiple methods for each possible event.
pub fn event_handler<H: EventHandler + 'static>(mut self, event_handler: H) -> Self {
self.event_handlers.push(Arc::new(event_handler));

self
}

/// Adds an event handler with multiple methods for each possible event. Passed by Arc.
pub fn event_handler_arc<H: EventHandler + 'static>(
mut self,
event_handler_arc: Arc<H>,
) -> Self {
self.event_handlers.push(event_handler_arc);
pub fn event_handler<H>(mut self, event_handler: impl Into<Arc<H>>) -> Self
where
H: EventHandler + 'static,
{
self.event_handlers.push(event_handler.into());

self
}
Expand Down