Added .songautodelete/.sad command.
This commit is contained in:
parent
e50e71014e
commit
fe3770270e
@ -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,6 +287,7 @@ namespace NadekoBot.Modules.Music.Common
|
||||
{
|
||||
_log.Info("Loading related song");
|
||||
await _musicService.TryQueueRelatedSongAsync(data.Song, OutputTextChannel, VoiceChannel);
|
||||
if(!AutoDelete)
|
||||
Queue.Next();
|
||||
}
|
||||
catch
|
||||
@ -327,7 +336,8 @@ namespace NadekoBot.Modules.Music.Common
|
||||
_log.Info("Next song");
|
||||
lock (locker)
|
||||
{
|
||||
if(!Stopped)
|
||||
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;
|
||||
|
@ -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)
|
||||
|
@ -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>
|
||||
|
@ -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.",
|
||||
|
Loading…
Reference in New Issue
Block a user