fixed bot handler play
This commit is contained in:
@@ -56,7 +56,7 @@ pub async fn run(ctx: &Context, command: &CommandInteraction) {
|
||||
Ok(channel_id) => {
|
||||
log::debug!("<{guild_id}> Play command executed on {channel_id} with track: {track_url:?}");
|
||||
// Handle the track url
|
||||
match play_track(ctx, manager, guild_id.to_owned(), track_url).await {
|
||||
match enqueue_track(ctx, manager, guild_id.to_owned(), track_url, true).await {
|
||||
Ok(count) => {
|
||||
let mut message = format!("Playing {} tracks", count);
|
||||
if count == 0 {
|
||||
@@ -79,11 +79,12 @@ pub async fn run(ctx: &Context, command: &CommandInteraction) {
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn play_track(
|
||||
pub async fn enqueue_track(
|
||||
ctx: &Context,
|
||||
manager: Arc<Songbird>,
|
||||
guild_id: GuildId,
|
||||
track_url: &str,
|
||||
play_now: bool,
|
||||
) -> SirenResult<i32> {
|
||||
let mut track_count = 0;
|
||||
if let Some(handler_lock) = manager.get(guild_id) {
|
||||
@@ -140,11 +141,7 @@ pub async fn play_track(
|
||||
};
|
||||
let track_handle: TrackHandle;
|
||||
let is_queue_empty = handler.queue().is_empty();
|
||||
if is_queue_empty {
|
||||
track_handle = handler.play_input(input);
|
||||
} else {
|
||||
track_handle = handler.enqueue_input(input).await;
|
||||
}
|
||||
track_handle = handler.enqueue_input(input).await;
|
||||
// Set the volume
|
||||
let _ = track_handle.set_volume(volume);
|
||||
let track_title = metadata.title.unwrap();
|
||||
@@ -159,6 +156,9 @@ pub async fn play_track(
|
||||
);
|
||||
track_count += 1;
|
||||
}
|
||||
if play_now && !handler.queue().is_empty() {
|
||||
handler.queue().resume();
|
||||
}
|
||||
}
|
||||
Ok(track_count)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user