From 0e4728d9c9d7ebe1b7b30a934e3282b7a6f7270b Mon Sep 17 00:00:00 2001 From: Master Kwoth Date: Tue, 11 Jul 2017 19:52:10 +0200 Subject: [PATCH] Fixed .play when queue is stopped. .play X will now also unstop the player --- .../Commands/UserPunishCommands.cs | 1 + src/NadekoBot/Services/Music/MusicPlayer.cs | 31 +++++++++++-------- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/src/NadekoBot/Modules/Administration/Commands/UserPunishCommands.cs b/src/NadekoBot/Modules/Administration/Commands/UserPunishCommands.cs index 79786bcf..8538c619 100644 --- a/src/NadekoBot/Modules/Administration/Commands/UserPunishCommands.cs +++ b/src/NadekoBot/Modules/Administration/Commands/UserPunishCommands.cs @@ -28,6 +28,7 @@ namespace NadekoBot.Modules.Administration _muteService = muteService; } + //todo move to service private async Task InternalWarn(IGuild guild, ulong userId, string modName, string reason) { if (string.IsNullOrWhiteSpace(reason)) diff --git a/src/NadekoBot/Services/Music/MusicPlayer.cs b/src/NadekoBot/Services/Music/MusicPlayer.cs index a6b0cbfb..56b47497 100644 --- a/src/NadekoBot/Services/Music/MusicPlayer.cs +++ b/src/NadekoBot/Services/Music/MusicPlayer.cs @@ -339,18 +339,6 @@ namespace NadekoBot.Services.Music } } - public void SetIndex(int index) - { - if (index < 0) - throw new ArgumentOutOfRangeException(nameof(index)); - lock (locker) - { - Queue.CurrentIndex = index; - manualIndex = true; - CancelCurrentSong(); - } - } - private async Task GetAudioClient(bool reconnect = false) { if (_audioClient == null || @@ -409,6 +397,21 @@ namespace NadekoBot.Services.Music } } + public void SetIndex(int index) + { + if (index < 0) + throw new ArgumentOutOfRangeException(nameof(index)); + lock (locker) + { + if (Exited) + return; + Queue.CurrentIndex = index; + manualIndex = true; + Stopped = false; + CancelCurrentSong(); + } + } + public void Next(int skipCount = 1) { lock (locker) @@ -420,9 +423,11 @@ namespace NadekoBot.Services.Music // It's a bit weird, but that's the least annoying solution if (!Stopped) Queue.Next(skipCount - 1); + else + Queue.CurrentIndex = 0; Stopped = false; - Unpause(); CancelCurrentSong(); + Unpause(); } }