From 51bfe8d206814b969183da470ec0ca1f619b1a71 Mon Sep 17 00:00:00 2001 From: Toastie Date: Sat, 17 Aug 2024 19:09:01 +1200 Subject: [PATCH] .whosplaying is now properly paginated --- src/EllieBot/Modules/Utility/Utility.cs | 34 +++++++++++++++---------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/src/EllieBot/Modules/Utility/Utility.cs b/src/EllieBot/Modules/Utility/Utility.cs index 154daba..dffad00 100644 --- a/src/EllieBot/Modules/Utility/Utility.cs +++ b/src/EllieBot/Modules/Utility/Utility.cs @@ -122,21 +122,27 @@ public partial class Utility : EllieModule } } - userNames.Shuffle(); - - var i = 0; - if (userNames.Count == 0) - { - await Response().Error(strs.nobody_playing_game).SendAsync(); - return; - } - - var users = userNames.GroupBy(_ => i++ / 2) - .Select(ig => string.Concat(ig.Select(el => $"• {el,-27}"))) - .Join('\n'); - await Response() - .Confirm(Format.Code(users)) + .Sanitize() + .Paginated() + .Items(userNames) + .PageSize(20) + .Page((names, _) => + { + if (names.Count == 0) + { + return _sender.CreateEmbed() + .WithErrorColor() + .WithDescription(GetText(strs.nobody_playing_game)); + } + + var eb = _sender.CreateEmbed() + .WithOkColor(); + + var users = names.Join('\n'); + + return eb.WithDescription(users); + }) .SendAsync(); }