Added .songautodelete/.sad command.

This commit is contained in:
Master Kwoth 2017-08-15 23:54:54 +02:00
parent e50e71014e
commit fe3770270e
4 changed files with 43 additions and 3 deletions

View File

@ -91,6 +91,7 @@ namespace NadekoBot.Modules.Music.Common
_fairPlay = value; _fairPlay = value;
} }
} }
public bool AutoDelete { get; set; }
public uint MaxPlaytimeSeconds { get; set; } public uint MaxPlaytimeSeconds { get; set; }
@ -256,10 +257,17 @@ namespace NadekoBot.Modules.Music.Common
int queueCount; int queueCount;
bool stopped; bool stopped;
int currentIndex;
lock (locker) lock (locker)
{ {
queueCount = Queue.Count; queueCount = Queue.Count;
stopped = Stopped; stopped = Stopped;
currentIndex = Queue.CurrentIndex;
}
if (AutoDelete && !RepeatCurrentSong && !RepeatPlaylist && data.Song != null)
{
Queue.RemoveSong(data.Song);
} }
if (!manualIndex && (!RepeatCurrentSong || manualSkip)) if (!manualIndex && (!RepeatCurrentSong || manualSkip))
@ -279,6 +287,7 @@ namespace NadekoBot.Modules.Music.Common
{ {
_log.Info("Loading related song"); _log.Info("Loading related song");
await _musicService.TryQueueRelatedSongAsync(data.Song, OutputTextChannel, VoiceChannel); await _musicService.TryQueueRelatedSongAsync(data.Song, OutputTextChannel, VoiceChannel);
if(!AutoDelete)
Queue.Next(); Queue.Next();
} }
catch catch
@ -327,7 +336,8 @@ namespace NadekoBot.Modules.Music.Common
_log.Info("Next song"); _log.Info("Next song");
lock (locker) lock (locker)
{ {
if(!Stopped) if (!Stopped)
if(!AutoDelete)
Queue.Next(); Queue.Next();
} }
} }
@ -423,6 +433,8 @@ namespace NadekoBot.Modules.Music.Common
{ {
if (Exited) if (Exited)
return; return;
if (AutoDelete && index >= Queue.CurrentIndex && index > 0)
index--;
Queue.CurrentIndex = index; Queue.CurrentIndex = index;
manualIndex = true; manualIndex = true;
Stopped = false; Stopped = false;

View File

@ -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] [NadekoCommand, Usage, Description, Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task SoundCloudQueue([Remainder] string query) public async Task SoundCloudQueue([Remainder] string query)

View File

@ -2826,6 +2826,15 @@
<data name="fairplay_usage" xml:space="preserve"> <data name="fairplay_usage" xml:space="preserve">
<value>`{0}fp`</value> <value>`{0}fp`</value>
</data> </data>
<data name="songautodelete_cmd" xml:space="preserve">
<value>songautodelete sad</value>
</data>
<data name="songautodelete_desc" xml:space="preserve">
<value>Toggles whether the song should be automatically removed from the music queue when it finishes playing.</value>
</data>
<data name="songautodelete_usage" xml:space="preserve">
<value>`{0}sad`</value>
</data>
<data name="define_cmd" xml:space="preserve"> <data name="define_cmd" xml:space="preserve">
<value>define def</value> <value>define def</value>
</data> </data>

View File

@ -411,6 +411,8 @@
"music_finished_song": "Finished song", "music_finished_song": "Finished song",
"music_fp_disabled": "Fair play disabled.", "music_fp_disabled": "Fair play disabled.",
"music_fp_enabled": "Fair play enabled.", "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_from_position": "From position",
"music_id": "Id", "music_id": "Id",
"music_invalid_input": "Invalid input.", "music_invalid_input": "Invalid input.",