paginated listing
This commit is contained in:
parent
3b3ac5496f
commit
f18d56e805
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -31,14 +31,12 @@ namespace NadekoBot.Classes.JSONModels
|
||||
"%user% did it 😒 🔫",
|
||||
"%target% did it 😒 🔫" } },
|
||||
{"%mention% insult", new List<string>() {
|
||||
"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<string>()
|
||||
{
|
||||
"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.",
|
||||
|
@ -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.",
|
||||
|
Loading…
Reference in New Issue
Block a user