readded %playing% and %queued% placeholders

This commit is contained in:
Master Kwoth 2017-07-05 13:31:41 +02:00
parent d089a37bf0
commit d0326ad680

View File

@ -89,25 +89,26 @@ namespace NadekoBot.DataStructures.Replacements
return this;
}
//public ReplacementBuilder WithMusic(MusicService ms)
//{
// _reps.TryAdd("%playing%", () =>
// {
// var cnt = ms.MusicPlayers.Count(kvp => kvp.Value.CurrentSong != null);
// if (cnt != 1) return cnt.ToString();
// try
// {
// var mp = ms.MusicPlayers.FirstOrDefault();
// return mp.Value.CurrentSong.SongInfo.Title;
// }
// catch
// {
// return "No songs";
// }
// });
// _reps.TryAdd("%queued%", () => ms.MusicPlayers.Sum(kvp => kvp.Value.Playlist.Count).ToString());
// return this;
//}
public ReplacementBuilder WithMusic(MusicService ms)
{
_reps.TryAdd("%playing%", () =>
{
var cnt = ms.MusicPlayers.Count(kvp => kvp.Value.Current.Current != null);
if (cnt != 1) return cnt.ToString();
try
{
var mp = ms.MusicPlayers.FirstOrDefault();
var title = mp.Value?.Current.Current?.Title;
return title ?? "No songs";
}
catch
{
return "error";
}
});
_reps.TryAdd("%queued%", () => ms.MusicPlayers.Sum(kvp => kvp.Value.QueueArray().Songs.Length).ToString());
return this;
}
public ReplacementBuilder WithRngRegex()
{