InactiveHandler on track end
This commit is contained in:
@@ -6,7 +6,7 @@ use serenity::model::application::interaction::{InteractionResponseType, applica
|
||||
use serenity::model::prelude::{GuildId, ChannelId};
|
||||
use serenity::model::user::User;
|
||||
use serenity::prelude::*;
|
||||
use songbird::Call;
|
||||
use songbird::{Call, Songbird};
|
||||
use songbird::input::{Restartable, Input, Metadata, error::Error as SongbirdError};
|
||||
|
||||
pub mod pause;
|
||||
@@ -39,7 +39,7 @@ pub async fn join(ctx: &Context, guild_id_option: &Option<GuildId>, user: &User)
|
||||
};
|
||||
|
||||
debug!("<{}> Joining channel {}", guild_id.0, channel_id);
|
||||
let manager = songbird::get(ctx).await.expect("Songbird Voice client placed in at initialization").clone();
|
||||
let manager = get_songbird(ctx).await;
|
||||
let (_handle_lock, success) = manager.join(guild_id.to_owned(), channel_id.to_owned()).await;
|
||||
match success {
|
||||
Ok(s) => Ok(s),
|
||||
@@ -63,7 +63,7 @@ pub async fn leave(ctx: &Context, guild_id_option: &Option<GuildId>) -> Result<(
|
||||
}
|
||||
};
|
||||
|
||||
let manager = songbird::get(ctx).await.expect("Songbird Voice client placed in at initialization").clone();
|
||||
let manager = get_songbird(ctx).await;
|
||||
if manager.get(*guild_id).is_some() {
|
||||
debug!("<{}> Disconnecting from channel", guild_id.0);
|
||||
if let Err(e) = manager.remove(*guild_id).await {
|
||||
@@ -161,3 +161,14 @@ fn is_valid_url(url: &str) -> bool {
|
||||
Err(_) => return false
|
||||
}
|
||||
}
|
||||
|
||||
/// Gets the Songbird voice client.
|
||||
///
|
||||
/// # Arguments
|
||||
/// - ctx - The context of the command.
|
||||
///
|
||||
/// # Returns
|
||||
/// Arc<Songbird> - The Songbird voice client.
|
||||
pub async fn get_songbird(ctx: &Context) -> Arc<Songbird> {
|
||||
songbird::get(ctx).await.expect("Songbird Voice client placed in at initialization")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user