Make sure that stats works with the inmemory database and add cookies
This commit is contained in:
parent
119f4586c7
commit
efaaf594f0
1 changed files with 12 additions and 8 deletions
|
@ -42,17 +42,20 @@ namespace Geekbot.net.Commands.User
|
||||||
var joinedDayAgo = Math.Floor((DateTime.Now - joinedAt).TotalDays);
|
var joinedDayAgo = Math.Floor((DateTime.Now - joinedAt).TotalDays);
|
||||||
|
|
||||||
var messages = _database.Messages
|
var messages = _database.Messages
|
||||||
.First(e => e.GuildId.Equals(Context.Guild.Id.AsLong()) && e.UserId.Equals(userInfo.Id.AsLong()))
|
?.FirstOrDefault(e => e.GuildId.Equals(Context.Guild.Id.AsLong()) && e.UserId.Equals(userInfo.Id.AsLong()))
|
||||||
.MessageCount;
|
?.MessageCount ?? 0;
|
||||||
var guildMessages = _database.Messages
|
var guildMessages = _database.Messages
|
||||||
.Where(e => e.GuildId.Equals(Context.Guild.Id.AsLong()))
|
?.Where(e => e.GuildId.Equals(Context.Guild.Id.AsLong()))
|
||||||
.Select(e => e.MessageCount)
|
.Select(e => e.MessageCount)
|
||||||
.Sum();
|
.Sum() ?? 0;
|
||||||
// var messages = (int) _redis.Db.HashGet($"{Context.Guild.Id}:Messages", userInfo.Id.ToString());
|
|
||||||
// var guildMessages = (int) _redis.Db.HashGet($"{Context.Guild.Id}:Messages", 0.ToString());
|
|
||||||
var level = _levelCalc.GetLevel(messages);
|
var level = _levelCalc.GetLevel(messages);
|
||||||
|
|
||||||
var percent = Math.Round((double) (100 * messages) / guildMessages, 2);
|
var percent = Math.Round((double) (100 * messages) / guildMessages, digits: 2);
|
||||||
|
|
||||||
|
var cookies = _database.Cookies
|
||||||
|
?.FirstOrDefault(e => e.GuildId.Equals(Context.Guild.Id.AsLong()) && e.UserId.Equals(userInfo.Id.AsLong()))
|
||||||
|
?.Cookies ?? 0;
|
||||||
|
|
||||||
var eb = new EmbedBuilder();
|
var eb = new EmbedBuilder();
|
||||||
eb.WithAuthor(new EmbedAuthorBuilder()
|
eb.WithAuthor(new EmbedAuthorBuilder()
|
||||||
|
@ -77,6 +80,7 @@ namespace Geekbot.net.Commands.User
|
||||||
.AddInlineField("Server Total", $"{percent}%");
|
.AddInlineField("Server Total", $"{percent}%");
|
||||||
|
|
||||||
if (correctRolls != null) eb.AddInlineField("Guessed Rolls", correctRolls.Rolls);
|
if (correctRolls != null) eb.AddInlineField("Guessed Rolls", correctRolls.Rolls);
|
||||||
|
if (cookies > 0) eb.AddInlineField("Cookies", cookies);
|
||||||
|
|
||||||
await ReplyAsync("", false, eb.Build());
|
await ReplyAsync("", false, eb.Build());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue