queue play command

This commit is contained in:
jude
2022-02-13 16:12:42 +00:00
parent 821f283969
commit febeeefb01
6 changed files with 187 additions and 5 deletions

View File

@ -18,7 +18,7 @@ use crate::{
};
pub async fn play_audio(
sound: &mut Sound,
sound: &Sound,
volume: u8,
call_handler: &mut MutexGuard<'_, Call>,
db_pool: impl Executor<'_, Database = Database>,
@ -39,6 +39,23 @@ pub async fn play_audio(
Ok(track_handler)
}
pub async fn queue_audio(
sounds: &[Sound],
volume: u8,
call_handler: &mut MutexGuard<'_, Call>,
db_pool: impl Executor<'_, Database = Database> + Copy,
) -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
for sound in sounds {
let (a, b) = create_player(sound.playable(db_pool).await?.into());
let _ = b.set_volume(volume as f32 / 100.0);
call_handler.enqueue(a);
}
Ok(())
}
pub async fn join_channel(
ctx: &poise::serenity_prelude::Context,
guild: Guild,