diff --git a/src/NadekoBot/Modules/Music/Common/MusicPlayer.cs b/src/NadekoBot/Modules/Music/Common/MusicPlayer.cs
index aed23c0e..aa61a9ce 100644
--- a/src/NadekoBot/Modules/Music/Common/MusicPlayer.cs
+++ b/src/NadekoBot/Modules/Music/Common/MusicPlayer.cs
@@ -91,6 +91,7 @@ namespace NadekoBot.Modules.Music.Common
_fairPlay = value;
}
}
+ public bool AutoDelete { get; set; }
public uint MaxPlaytimeSeconds { get; set; }
@@ -256,10 +257,17 @@ namespace NadekoBot.Modules.Music.Common
int queueCount;
bool stopped;
+ int currentIndex;
lock (locker)
{
queueCount = Queue.Count;
stopped = Stopped;
+ currentIndex = Queue.CurrentIndex;
+ }
+
+ if (AutoDelete && !RepeatCurrentSong && !RepeatPlaylist && data.Song != null)
+ {
+ Queue.RemoveSong(data.Song);
}
if (!manualIndex && (!RepeatCurrentSong || manualSkip))
@@ -279,7 +287,8 @@ namespace NadekoBot.Modules.Music.Common
{
_log.Info("Loading related song");
await _musicService.TryQueueRelatedSongAsync(data.Song, OutputTextChannel, VoiceChannel);
- Queue.Next();
+ if(!AutoDelete)
+ Queue.Next();
}
catch
{
@@ -327,8 +336,9 @@ namespace NadekoBot.Modules.Music.Common
_log.Info("Next song");
lock (locker)
{
- if(!Stopped)
- Queue.Next();
+ if (!Stopped)
+ if(!AutoDelete)
+ Queue.Next();
}
}
}
@@ -423,6 +433,8 @@ namespace NadekoBot.Modules.Music.Common
{
if (Exited)
return;
+ if (AutoDelete && index >= Queue.CurrentIndex && index > 0)
+ index--;
Queue.CurrentIndex = index;
manualIndex = true;
Stopped = false;
diff --git a/src/NadekoBot/Modules/Music/Music.cs b/src/NadekoBot/Modules/Music/Music.cs
index 5589984a..a5b0295e 100644
--- a/src/NadekoBot/Modules/Music/Music.cs
+++ b/src/NadekoBot/Modules/Music/Music.cs
@@ -578,6 +578,23 @@ namespace NadekoBot.Modules.Music
}
}
+ [NadekoCommand, Usage, Description, Aliases]
+ [RequireContext(ContextType.Guild)]
+ public async Task SongAutoDelete()
+ {
+ var mp = await _service.GetOrCreatePlayer(Context);
+ var val = mp.AutoDelete = !mp.AutoDelete;
+
+ if (val)
+ {
+ await ReplyConfirmLocalized("sad_enabled").ConfigureAwait(false);
+ }
+ else
+ {
+ await ReplyConfirmLocalized("sad_disabled").ConfigureAwait(false);
+ }
+ }
+
[NadekoCommand, Usage, Description, Aliases]
[RequireContext(ContextType.Guild)]
public async Task SoundCloudQueue([Remainder] string query)
diff --git a/src/NadekoBot/Resources/CommandStrings.resx b/src/NadekoBot/Resources/CommandStrings.resx
index cf106686..743a1689 100644
--- a/src/NadekoBot/Resources/CommandStrings.resx
+++ b/src/NadekoBot/Resources/CommandStrings.resx
@@ -2826,6 +2826,15 @@
`{0}fp`
+
+ songautodelete sad
+
+
+ Toggles whether the song should be automatically removed from the music queue when it finishes playing.
+
+
+ `{0}sad`
+
define def
diff --git a/src/NadekoBot/_strings/ResponseStrings.en-US.json b/src/NadekoBot/_strings/ResponseStrings.en-US.json
index 84a236d4..42c5998f 100644
--- a/src/NadekoBot/_strings/ResponseStrings.en-US.json
+++ b/src/NadekoBot/_strings/ResponseStrings.en-US.json
@@ -411,6 +411,8 @@
"music_finished_song": "Finished song",
"music_fp_disabled": "Fair play disabled.",
"music_fp_enabled": "Fair play enabled.",
+ "music_sad_disabled": "Songs will be deleted from the music queue when they finish playing.",
+ "music_sad_enabled": "Songs will no longer be deleted from the music queue when they finish playing.",
"music_from_position": "From position",
"music_id": "Id",
"music_invalid_input": "Invalid input.",