Added .liqu command which lists quotes

This commit is contained in:
Kwoth
2016-10-27 12:36:42 +02:00
parent 84a0fc4c8f
commit 828eb29b5c
5 changed files with 64 additions and 0 deletions

View File

@@ -15,6 +15,30 @@ namespace NadekoBot.Modules.Utility
{
public partial class Utility
{
[NadekoCommand, Usage, Description, Aliases]
[RequireContext(ContextType.Guild)]
public async Task ListQuotes(IUserMessage imsg, int page = 1)
{
var channel = (ITextChannel)imsg.Channel;
page -= 1;
if (page < 0)
return;
IEnumerable<Quote> quotes;
using (var uow = DbHandler.UnitOfWork())
{
quotes = uow.Quotes.GetGroup(page * 16, 16);
}
if (quotes.Any())
await channel.SendMessageAsync($"`Page {page + 1} of quotes:`\n```xl\n" + String.Join("\n", quotes.Select((q) => $"{q.Keyword,-20} by {q.AuthorName}")) + "\n```")
.ConfigureAwait(false);
else
await channel.SendMessageAsync("`No quotes on this page.`").ConfigureAwait(false);
}
[NadekoCommand, Usage, Description, Aliases]
[RequireContext(ContextType.Guild)]
public async Task ShowQuote(IUserMessage umsg, [Remainder] string keyword)