paginated listing
This commit is contained in:
parent
3b3ac5496f
commit
f18d56e805
@ -54,28 +54,14 @@ namespace NadekoBot.Modules.Administration.Commands
|
|||||||
|
|
||||||
cgb.CreateCommand(Prefix + "listcustomreactions")
|
cgb.CreateCommand(Prefix + "listcustomreactions")
|
||||||
.Alias(Prefix + "lcr")
|
.Alias(Prefix + "lcr")
|
||||||
.Description("Lists all current custom reactions. **Owner Only!**")
|
.Description("Lists all current custom reactions (paginated with 5 commands per page).\n**Usage**:.lcr 1")
|
||||||
.AddCheck(SimpleCheckers.OwnerOnly())
|
.Parameter("num", ParameterType.Required)
|
||||||
.Do(async e =>
|
.Do(async e =>
|
||||||
{
|
{
|
||||||
|
int num;
|
||||||
string message = $"Custom reactions:";
|
if (!int.TryParse(e.GetArg("num"), out num)) return;
|
||||||
foreach (var cr in NadekoBot.Config.CustomReactions)
|
string result = getCustomsOnPage(num -1); //People prefer starting with 1
|
||||||
{
|
await e.Channel.SendMessage(result);
|
||||||
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);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand(Prefix + "deletecustomreaction")
|
cgb.CreateCommand(Prefix + "deletecustomreaction")
|
||||||
@ -119,5 +105,27 @@ namespace NadekoBot.Modules.Administration.Commands
|
|||||||
await e.Channel.SendMessage(message);
|
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 😒 🔫",
|
"%user% did it 😒 🔫",
|
||||||
"%target% did it 😒 🔫" } },
|
"%target% did it 😒 🔫" } },
|
||||||
{"%mention% insult", new List<string>() {
|
{"%mention% insult", new List<string>() {
|
||||||
"I would never insult %owner%, my beloved master.",
|
|
||||||
"%target% You are a poop.",
|
"%target% You are a poop.",
|
||||||
"%target% You're a jerk.",
|
"%target% You're a jerk.",
|
||||||
"%target% I will eat you when I get my powers back."
|
"%target% I will eat you when I get my powers back."
|
||||||
} },
|
} },
|
||||||
{"%mention% praise", new List<string>()
|
{"%mention% praise", new List<string>()
|
||||||
{
|
{
|
||||||
"I don't need your permission to praise %owner%, my beloved master",
|
|
||||||
"%target% You are cool.",
|
"%target% You are cool.",
|
||||||
"%target% You are nice!",
|
"%target% You are nice!",
|
||||||
"%target% You did a good job.",
|
"%target% You did a good job.",
|
||||||
|
@ -20,13 +20,11 @@
|
|||||||
"%target% did it 😒 🔫"
|
"%target% did it 😒 🔫"
|
||||||
],
|
],
|
||||||
"%mention% insult": [
|
"%mention% insult": [
|
||||||
"I would never insult %owner%, my beloved master.",
|
|
||||||
"%target% You are a poop.",
|
"%target% You are a poop.",
|
||||||
"%target% You're a jerk.",
|
"%target% You're a jerk.",
|
||||||
"%target% I will eat you when I get my powers back."
|
"%target% I will eat you when I get my powers back."
|
||||||
],
|
],
|
||||||
"%mention% praise": [
|
"%mention% praise": [
|
||||||
"I don't need your permission to praise %owner%, my beloved master",
|
|
||||||
"%target% You are cool.",
|
"%target% You are cool.",
|
||||||
"%target% You are nice!",
|
"%target% You are nice!",
|
||||||
"%target% You did a good job.",
|
"%target% You did a good job.",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user