!m pls added, thanks to Keskitariv for the suggestion
This commit is contained in:
parent
e17a320301
commit
6f067f219b
@ -158,9 +158,35 @@ namespace NadekoBot.Classes
|
|||||||
return conn.Table<T>().Where(p).ToList().OrderBy(x => r.Next()).FirstOrDefault();
|
return conn.Table<T>().Where(p).ToList().OrderBy(x => r.Next()).FirstOrDefault();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="num">Page number (0+)</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
internal List<PlaylistData> GetPlaylistData(int num)
|
||||||
|
{
|
||||||
|
using (var conn = new SQLiteConnection(FilePath))
|
||||||
|
{
|
||||||
|
return conn.Query<PlaylistData>(
|
||||||
|
@"SELECT mp.Name as 'Name',mp.Id as 'Id', mp.CreatorName as 'Creator', Count(*) as 'SongCnt' FROM MusicPlaylist as mp
|
||||||
|
INNER JOIN PlaylistSongInfo as psi
|
||||||
|
ON mp.Id = psi.PlaylistId
|
||||||
|
Group BY mp.Name
|
||||||
|
Order By mp.DateAdded desc
|
||||||
|
Limit 20 OFFSET ?", num * 20);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class PlaylistData
|
||||||
|
{
|
||||||
|
public string Name { get; set; }
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string Creator { get; set; }
|
||||||
|
public int SongCnt { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
public static class Queries
|
public static class Queries
|
||||||
{
|
{
|
||||||
public static string TransactionTriggerQuery = @"
|
public static string TransactionTriggerQuery = @"
|
||||||
|
@ -219,9 +219,10 @@ namespace NadekoBot
|
|||||||
DateAdded = DateTime.Now
|
DateAdded = DateTime.Now
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
catch
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Error in ran command DB write.");
|
Console.WriteLine("Probably unimportant error in ran command DB write.");
|
||||||
|
Console.WriteLine(ex);
|
||||||
}
|
}
|
||||||
}).ConfigureAwait(false);
|
}).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
@ -488,16 +488,6 @@ namespace NadekoBot.Modules.Music
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
//cgb.CreateCommand("info")
|
|
||||||
// .Description("Prints music info (queued/finished/playing) only to this channel")
|
|
||||||
// .Do(async e =>
|
|
||||||
// {
|
|
||||||
// MusicPlayer musicPlayer;
|
|
||||||
// if (!MusicPlayers.TryGetValue(e.Server, out musicPlayer))
|
|
||||||
// return;
|
|
||||||
// musicPlayer
|
|
||||||
// });
|
|
||||||
|
|
||||||
cgb.CreateCommand("load")
|
cgb.CreateCommand("load")
|
||||||
.Description("Loads a playlist under a certain name. \n**Usage**: `!m load classical-1`")
|
.Description("Loads a playlist under a certain name. \n**Usage**: `!m load classical-1`")
|
||||||
.Parameter("name", ParameterType.Unparsed)
|
.Parameter("name", ParameterType.Unparsed)
|
||||||
@ -553,6 +543,23 @@ namespace NadekoBot.Modules.Music
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
cgb.CreateCommand("playlists")
|
||||||
|
.Alias("pls")
|
||||||
|
.Description("Lists all playlists. Paginated. 20 per page. Default page is 0.\n**Usage**:`!m pls 1`")
|
||||||
|
.Parameter("num", ParameterType.Optional)
|
||||||
|
.Do(e =>
|
||||||
|
{
|
||||||
|
int num = 0;
|
||||||
|
int.TryParse(e.GetArg("num"), out num);
|
||||||
|
if (num < 0)
|
||||||
|
return;
|
||||||
|
var result = DbHandler.Instance.GetPlaylistData(num);
|
||||||
|
if (result.Count == 0)
|
||||||
|
e.Channel.SendMessage($"`No saved playlists found on page {num}`");
|
||||||
|
else
|
||||||
|
e.Channel.SendMessage($"```js\n--- List of saved playlists ---\n\n" + string.Join("\n", result.Select(r => $"'{r.Name}-{r.Id}' by {r.Creator} ({r.SongCnt} songs)")) + $"\n\n --- Page {num} ---```");
|
||||||
|
});
|
||||||
|
|
||||||
cgb.CreateCommand("goto")
|
cgb.CreateCommand("goto")
|
||||||
.Description("Goes to a specific time in seconds in a song.")
|
.Description("Goes to a specific time in seconds in a song.")
|
||||||
.Parameter("time")
|
.Parameter("time")
|
||||||
|
Loading…
Reference in New Issue
Block a user