From b7c8bf504c4c1c229e8e595f82a5b48694f1cf83 Mon Sep 17 00:00:00 2001 From: Master Kwoth Date: Sat, 14 May 2016 20:20:49 +0200 Subject: [PATCH] .whoplays command added --- .../Administration/AdministrationModule.cs | 19 +++++++++++++++++++ .../Modules/Music/Classes/MusicControls.cs | 10 ++++++---- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/NadekoBot/Modules/Administration/AdministrationModule.cs b/NadekoBot/Modules/Administration/AdministrationModule.cs index b7991ab3..412eb8d8 100644 --- a/NadekoBot/Modules/Administration/AdministrationModule.cs +++ b/NadekoBot/Modules/Administration/AdministrationModule.cs @@ -946,6 +946,25 @@ namespace NadekoBot.Modules.Administration await e.Channel.SendMessage(":ok:"); }); + cgb.CreateCommand(Prefix + "whoplays") + .Description("Shows a list of users who are playing the specified game") + .Parameter("game") + .Do(async e => + { + var game = e.GetArg("game").Trim().ToUpperInvariant(); + var en = e.Server.Users + .Where(u => u.CurrentGame?.ToUpperInvariant() == game) + .Select(u => $"{u.Name}"); + + var arr = en as string[] ?? en.ToArray(); + + if (arr.Length == 0) + await e.Channel.SendMessage("Nobody. (not 100% sure)"); + else + await e.Channel.SendMessage("• " + string.Join("\n• ", arr)); + + }); + }); } diff --git a/NadekoBot/Modules/Music/Classes/MusicControls.cs b/NadekoBot/Modules/Music/Classes/MusicControls.cs index 4833dda8..6180706a 100644 --- a/NadekoBot/Modules/Music/Classes/MusicControls.cs +++ b/NadekoBot/Modules/Music/Classes/MusicControls.cs @@ -95,10 +95,12 @@ namespace NadekoBot.Modules.Music.Classes Console.WriteLine($"Exception in PlaySong: {ex}"); } OnCompleted(this, curSong); - if (RepeatSong) - playlist.Insert(0, curSong); - else if (RepeatPlaylist) - playlist.Insert(playlist.Count, curSong); + curSong = CurrentSong; //to check if its null now + if (curSong != null) + if (RepeatSong) + playlist.Insert(0, curSong); + else if (RepeatPlaylist) + playlist.Insert(playlist.Count, curSong); SongCancelSource = new CancellationTokenSource(); cancelToken = SongCancelSource.Token; }