public async Task StatsAsync( [Summary("The user for which to retrieve statistics. If no user is specified, the invoking user is used.")] SocketUser user = null) { user = user ?? Context.User; CommandUse[] commands = await DataBaseUtil.GetCommandsAsync(user.Id); Shitpost[] shitposts = await DataBaseUtil.GetShitpostsAsync(user.Id); Mute[] mutes = await DataBaseUtil.GetMutesAsync(user.Id); EmbedBuilder embed = new EmbedBuilder().WithAuthor($"Stats for {user}", user.GetAvatarUrl()); if (commands.Any()) { string fav = commands.GroupBy(r => r.command).OrderByDescending(g => g.Count()).Select(g => g.Key).First(); int favCount = commands.Count(c => c.command == fav); embed.AddField("Command Usage", $"Total: `{commands.Length}`\nFavorite: `{fav}` ({favCount})"); } if (shitposts.Any()) { string fav = shitposts.GroupBy(r => r.shitpost).OrderByDescending(g => g.Count()).Select(g => g.Key).First(); int favCount = shitposts.Count(c => c.shitpost == fav); embed.AddField("Shitpost Usage", $"Total: `{shitposts.Length}`\nFavorite: `{fav}` ({favCount})"); } if (mutes.Any()) { Mute mute = mutes.First(); string value = $"Total: {mutes.Length}\nTimestamp: `{mute.Timestamp:yyyy-MM-ddTHH:mm:ssZ}`\nDuration: `"; if (mute.Duration.HasValue) { value += mute.Duration + (mute.Duration == 1 ? "` minute" : "` minutes"); } else { value += "indefinite`"; } if (mute.Reason != null) { value += $"\nReason: `{mute.Reason}`"; } embed.AddField("Latest Mute Information", value); } await ReplyAsync(string.Empty, embed : embed.Build()); await DataBaseUtil.AddCommandAsync("Stats", Context); }