Fix changing volume on skip
This commit is contained in:
parent
d342a5eab5
commit
db8c82578a
1 changed files with 1 additions and 40 deletions
|
@ -1,5 +1,4 @@
|
|||
use serenity;
|
||||
use serenity::voice::ffmpeg;
|
||||
|
||||
use super::super::prelude::*;
|
||||
|
||||
|
@ -21,45 +20,7 @@ fn skip(ctx: &mut Context, msg: &Message, _: Args) -> CommandResult {
|
|||
if let Some(media) = data.get_mut::<Media>() {
|
||||
let mut media_lock = media.lock().unwrap();
|
||||
|
||||
let voice_manager = media_lock.voice_manager.clone();
|
||||
let mut manager = voice_manager.lock();
|
||||
|
||||
let guild_id = guild_id(ctx, msg)?;
|
||||
|
||||
if let Some(handler) = handler(guild_id, &mut manager) {
|
||||
// if current song is the last song in this playlist, just return
|
||||
if media_lock.playlist().is_empty() {
|
||||
msg.channel_id
|
||||
.say(&ctx.http, "playlist is empty, no next song available")?;
|
||||
|
||||
return Ok(());
|
||||
} else {
|
||||
// remove the current song from the playlist
|
||||
let first = media_lock.playlist_mut().remove(0);
|
||||
|
||||
// stop the current song from playing
|
||||
handler.stop();
|
||||
|
||||
// load next song into memory
|
||||
let source = match ffmpeg(first.name.clone()) {
|
||||
Ok(mpeg) => mpeg,
|
||||
Err(_) => {
|
||||
media_lock.playlist_mut().clear();
|
||||
*media_lock.song_mut() = None;
|
||||
|
||||
return Ok(());
|
||||
}
|
||||
};
|
||||
|
||||
*media_lock.song_mut() = Some(handler.play_returning(source));
|
||||
*media_lock.song_name_mut() = first.name.clone();
|
||||
|
||||
msg.channel_id.say(
|
||||
&ctx.http,
|
||||
format!("Skipped current song, now playing: {}", first.name),
|
||||
)?;
|
||||
}
|
||||
}
|
||||
MediaData::next_song(ctx, &mut media_lock, msg)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
|
Loading…
Reference in a new issue