Add total quotes of a user to !stats

This commit is contained in:
Daan Boerlage 2021-04-20 22:25:33 +02:00
parent 8bd8efa66a
commit 5a50ba5820
Signed by: daan
GPG key ID: FCE070E1E4956606
4 changed files with 35 additions and 2 deletions

View file

@ -54,6 +54,8 @@ namespace Geekbot.Bot.Commands.User
?.FirstOrDefault(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()))
?.Cookies ?? 0; ?.Cookies ?? 0;
var quotes = _database.Quotes.Count(e => e.GuildId.Equals(Context.Guild.Id.AsLong()) && e.UserId.Equals(userInfo.Id.AsLong()));
var eb = new EmbedBuilder(); var eb = new EmbedBuilder();
eb.WithAuthor(new EmbedAuthorBuilder() eb.WithAuthor(new EmbedAuthorBuilder()
.WithIconUrl(userInfo.GetAvatarUrl()) .WithIconUrl(userInfo.GetAvatarUrl())
@ -68,9 +70,9 @@ namespace Geekbot.Bot.Commands.User
e.UserId.Equals(userInfo.Id.AsLong())); e.UserId.Equals(userInfo.Id.AsLong()));
eb.AddInlineField(Localization.Stats.OnDiscordSince, eb.AddInlineField(Localization.Stats.OnDiscordSince,
$"{createdAt.Day}.{createdAt.Month}.{createdAt.Year} ({age} days)") $"{createdAt.Day}.{createdAt.Month}.{createdAt.Year} ({age} {Localization.Stats.Days})")
.AddInlineField(Localization.Stats.JoinedServer, .AddInlineField(Localization.Stats.JoinedServer,
$"{joinedAt.Day}.{joinedAt.Month}.{joinedAt.Year} ({joinedDayAgo} days)") $"{joinedAt.Day}.{joinedAt.Month}.{joinedAt.Year} ({joinedDayAgo} {Localization.Stats.Days})")
.AddInlineField(Localization.Stats.Karma, karma?.Karma ?? 0) .AddInlineField(Localization.Stats.Karma, karma?.Karma ?? 0)
.AddInlineField(Localization.Stats.Level, level) .AddInlineField(Localization.Stats.Level, level)
.AddInlineField(Localization.Stats.MessagesSent, messages) .AddInlineField(Localization.Stats.MessagesSent, messages)
@ -78,6 +80,7 @@ namespace Geekbot.Bot.Commands.User
if (correctRolls != null) eb.AddInlineField(Localization.Stats.GuessedRolls, correctRolls.Rolls); if (correctRolls != null) eb.AddInlineField(Localization.Stats.GuessedRolls, correctRolls.Rolls);
if (cookies > 0) eb.AddInlineField(Localization.Stats.Cookies, cookies); if (cookies > 0) eb.AddInlineField(Localization.Stats.Cookies, cookies);
if (quotes > 0) eb.AddInlineField(Localization.Stats.Quotes, quotes);
await ReplyAsync("", false, eb.Build()); await ReplyAsync("", false, eb.Build());
} }

View file

@ -69,6 +69,15 @@ namespace Geekbot.Bot.Localization {
} }
} }
/// <summary>
/// Looks up a localized string similar to Days.
/// </summary>
internal static string Days {
get {
return ResourceManager.GetString("Days", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to Guessed Rolls. /// Looks up a localized string similar to Guessed Rolls.
/// </summary> /// </summary>
@ -123,6 +132,15 @@ namespace Geekbot.Bot.Localization {
} }
} }
/// <summary>
/// Looks up a localized string similar to Quotes.
/// </summary>
internal static string Quotes {
get {
return ResourceManager.GetString("Quotes", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to Server Total. /// Looks up a localized string similar to Server Total.
/// </summary> /// </summary>

View file

@ -35,4 +35,10 @@
<data name="Cookies" xml:space="preserve"> <data name="Cookies" xml:space="preserve">
<value>Guetzli</value> <value>Guetzli</value>
</data> </data>
<data name="Days" xml:space="preserve">
<value>Täg</value>
</data>
<data name="Quotes" xml:space="preserve">
<value>Quotes</value>
</data>
</root> </root>

View file

@ -42,4 +42,10 @@
<data name="Cookies" xml:space="preserve"> <data name="Cookies" xml:space="preserve">
<value>Cookies</value> <value>Cookies</value>
</data> </data>
<data name="Days" xml:space="preserve">
<value>Days</value>
</data>
<data name="Quotes" xml:space="preserve">
<value>Quotes</value>
</data>
</root> </root>