diff --git a/NadekoBot/Modules/Administration/Commands/CustomReactionsCommands.cs b/NadekoBot/Modules/Administration/Commands/CustomReactionsCommands.cs index 781226e6..c9de745e 100644 --- a/NadekoBot/Modules/Administration/Commands/CustomReactionsCommands.cs +++ b/NadekoBot/Modules/Administration/Commands/CustomReactionsCommands.cs @@ -54,28 +54,14 @@ namespace NadekoBot.Modules.Administration.Commands cgb.CreateCommand(Prefix + "listcustomreactions") .Alias(Prefix + "lcr") - .Description("Lists all current custom reactions. **Owner Only!**") - .AddCheck(SimpleCheckers.OwnerOnly()) + .Description("Lists all current custom reactions (paginated with 5 commands per page).\n**Usage**:.lcr 1") + .Parameter("num", ParameterType.Required) .Do(async e => { - - string message = $"Custom reactions:"; - foreach (var cr in NadekoBot.Config.CustomReactions) - { - if (message.Length > 1500) - { - await e.Channel.SendMessage(message).ConfigureAwait(false); - message = ""; - } - message += $"\n**\"{Format.Escape(cr.Key)}\"**:"; - int i = 1; - foreach (var reaction in cr.Value) - { - message += "\n " + i++ + "." + Format.Code(reaction); - } - - } - await e.Channel.SendMessage(message); + int num; + if (!int.TryParse(e.GetArg("num"), out num)) return; + string result = getCustomsOnPage(num -1); //People prefer starting with 1 + await e.Channel.SendMessage(result); }); cgb.CreateCommand(Prefix + "deletecustomreaction") @@ -119,5 +105,27 @@ namespace NadekoBot.Modules.Administration.Commands await e.Channel.SendMessage(message); }); } + + private readonly int ItemsPerPage = 5; + + private string getCustomsOnPage(int page) + { + var items = NadekoBot.Config.CustomReactions.Skip(page * ItemsPerPage).Take(ItemsPerPage); + if(!items.Any()) + { + return $"No items on page {page}."; + } + string message = $"Custom reactions of page {page + 1}:"; + foreach (var cr in items) + { + message += $"\n**\"{Format.Escape(cr.Key)}\"**:"; + int i = 1; + foreach (var reaction in cr.Value) + { + message += "\n " + i++ + "." + Format.Code(reaction); + } + } + return message; + } } } diff --git a/NadekoBot/_Models/JSONModels/Configuration.cs b/NadekoBot/_Models/JSONModels/Configuration.cs index 51ba0e85..e03286d5 100644 --- a/NadekoBot/_Models/JSONModels/Configuration.cs +++ b/NadekoBot/_Models/JSONModels/Configuration.cs @@ -31,14 +31,12 @@ namespace NadekoBot.Classes.JSONModels "%user% did it 😒 🔫", "%target% did it 😒 🔫" } }, {"%mention% insult", new List() { - "I would never insult %owner%, my beloved master.", "%target% You are a poop.", "%target% You're a jerk.", "%target% I will eat you when I get my powers back." } }, {"%mention% praise", new List() { - "I don't need your permission to praise %owner%, my beloved master", "%target% You are cool.", "%target% You are nice!", "%target% You did a good job.", diff --git a/NadekoBot/bin/Debug/data/config_example.json b/NadekoBot/bin/Debug/data/config_example.json index 50d6604d..09fe148d 100644 --- a/NadekoBot/bin/Debug/data/config_example.json +++ b/NadekoBot/bin/Debug/data/config_example.json @@ -20,13 +20,11 @@ "%target% did it 😒 🔫" ], "%mention% insult": [ - "I would never insult %owner%, my beloved master.", "%target% You are a poop.", "%target% You're a jerk.", "%target% I will eat you when I get my powers back." ], "%mention% praise": [ - "I don't need your permission to praise %owner%, my beloved master", "%target% You are cool.", "%target% You are nice!", "%target% You did a good job.",