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;
}
}
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;

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]
[RequireContext(ContextType.Guild)]
public async Task SoundCloudQueue([Remainder] string query)

View File

@ -2826,6 +2826,15 @@
<data name="fairplay_usage" xml:space="preserve">
<value>`{0}fp`</value>
</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">
<value>define def</value>
</data>

View File

@ -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.",