Add support for !rank quote

This commit is contained in:
Daan Boerlage 2020-12-30 23:31:15 +01:00
parent 17f62d7607
commit 8bdf2e9681
Signed by: daan
GPG key ID: FCE070E1E4956606
3 changed files with 16 additions and 3 deletions

View file

@ -147,8 +147,8 @@ namespace Geekbot.Bot.Commands.Utils.Quote
.Where(row => row.GuildId == Context.Guild.Id.AsLong())
.GroupBy(row => row.UserId)
.Select(row => new { userId = row.Key, amount = row.Count()})
.OrderBy(row => row.amount)
.Last();
.OrderByDescending(row => row.amount)
.First();
var mostQuotedPersonUser = Context.Client.GetUserAsync(mostQuotedPerson.userId.AsUlong()).Result ?? new UserPolyfillDto {Username = "Unknown User"};
var quotesByYear = _database.Quotes

View file

@ -27,6 +27,7 @@ namespace Geekbot.Core.Highscores
HighscoreTypes.rolls => GetRollsList(guildId, amount),
HighscoreTypes.cookies => GetCookiesList(guildId, amount),
HighscoreTypes.seasons => GetMessageSeasonList(guildId, amount, season),
HighscoreTypes.quotes => GetQuotesList(guildId, amount),
_ => new Dictionary<ulong, int>()
};
@ -115,5 +116,16 @@ namespace Geekbot.Core.Highscores
.Take(amount)
.ToDictionary(key => key.UserId.AsUlong(), key => key.Cookies);
}
private Dictionary<ulong, int> GetQuotesList(ulong guildId, int amount)
{
return _database.Quotes
.Where(row => row.GuildId == guildId.AsLong())
.GroupBy(row => row.UserId)
.Select(row => new { userId = row.Key, amount = row.Count()})
.OrderByDescending(row => row.amount)
.Take(amount)
.ToDictionary(key => key.userId.AsUlong(), key => key.amount);
}
}
}

View file

@ -6,6 +6,7 @@
karma,
rolls,
cookies,
seasons
seasons,
quotes
}
}