stop command

This commit is contained in:
jude-lafitteIII 2020-05-22 15:28:25 +01:00
parent bcfb216b34
commit 086ed93a51

View File

@ -115,7 +115,7 @@ lazy_static! {
struct AllUsers; struct AllUsers;
#[group] #[group]
#[commands(play, upload_new_sound, change_volume, delete_sound)] #[commands(play, upload_new_sound, change_volume, delete_sound, stop_playing)]
#[checks(role_check)] #[checks(role_check)]
struct RoleManagedUsers; struct RoleManagedUsers;
@ -397,12 +397,9 @@ async fn disconnect_from_inactive(voice_manager_mutex: Arc<SerenityMutex<ClientV
if let Some(manager) = manager_opt { if let Some(manager) = manager_opt {
manager.leave(); manager.leave();
to_remove.insert(guild.clone());
} }
else {
to_remove.insert(guild.clone()); to_remove.insert(guild.clone());
} }
}
else { else {
*ticker -= 1; *ticker -= 1;
} }
@ -1019,3 +1016,19 @@ WHERE
Ok(()) Ok(())
} }
#[command("stop")]
async fn stop_playing(ctx: &Context, msg: &Message, _args: Args) -> CommandResult {
let voice_manager_lock = ctx.data.read().await
.get::<VoiceManager>().cloned().expect("Could not get VoiceManager from data");
let mut voice_manager = voice_manager_lock.lock().await;
let manager_opt = voice_manager.get_mut(msg.guild_id.unwrap());
if let Some(manager) = manager_opt {
manager.leave();
}
Ok(())
}