diff --git a/NadekoBot/Classes/_DataModels/MusicPlaylist.cs b/NadekoBot/Classes/_DataModels/MusicPlaylist.cs new file mode 100644 index 00000000..ff998690 --- /dev/null +++ b/NadekoBot/Classes/_DataModels/MusicPlaylist.cs @@ -0,0 +1,29 @@ +using SQLite; +using System.Collections.Generic; + +namespace NadekoBot.Classes._DataModels +{ + internal class MusicPlaylist : IDataModel + { + [Unique] + public string Name { get; set; } + public long CreatorId { get; set; } + public string CreatorName { get; set; } + public List Songs { get; set; } + } + + [System.Serializable] + internal class SongInfo + { + public string Name { get; set; } + public string Link { get; set; } + public SongType Type { get; set; } + } + + internal enum SongType + { + Local, + Radio, + Query + } +} diff --git a/NadekoBot/Modules/Music.cs b/NadekoBot/Modules/Music.cs index 4a974c42..b324d3f2 100644 --- a/NadekoBot/Modules/Music.cs +++ b/NadekoBot/Modules/Music.cs @@ -7,6 +7,7 @@ using NadekoBot.Classes.Permissions; using NadekoBot.Extensions; using System; using System.Collections.Concurrent; +using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Timer = System.Timers.Timer; @@ -416,6 +417,32 @@ namespace NadekoBot.Modules var currentValue = musicPlayer.ToggleRepeatPlaylist(); await e.Channel.SendMessage($"🎵🔁`Repeat playlist {(currentValue ? "enabled" : "disabled")}`"); }); + + cgb.CreateCommand("pls") + .Alias("playlistsave") + .Description("Saves a playlist under a certain name. Name must be no longer than 20 characters and mustn't contain dashes.\n**Usage**: `!m pls classical1`") + .Parameter("name", ParameterType.Unparsed) + .Do(async e => + { + var name = e.GetArg("name")?.Trim(); + + if (string.IsNullOrWhiteSpace(name) || + name.Length > 20 || + name.Contains("-")) + return; + + MusicPlayer musicPlayer; + if (!MusicPlayers.TryGetValue(e.Server, out musicPlayer)) + return; + + //to avoid concurrency issues + var currentPlaylist = new List(musicPlayer.Playlist); + + if (!currentPlaylist.Any()) + return; + + + }); //cgb.CreateCommand("debug") // .Description("Does something magical. **BOT OWNER ONLY**") // .AddCheck(Classes.Permissions.SimpleCheckers.OwnerOnly()) diff --git a/NadekoBot/NadekoBot.csproj b/NadekoBot/NadekoBot.csproj index 26d675a1..a6bf552a 100644 --- a/NadekoBot/NadekoBot.csproj +++ b/NadekoBot/NadekoBot.csproj @@ -151,6 +151,7 @@ +