2017-04-12 21:49:04 +02:00
|
|
|
|
using System;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Discord;
|
|
|
|
|
using Discord.Commands;
|
2017-04-14 21:36:01 +02:00
|
|
|
|
using Geekbot.net.Lib;
|
2017-05-06 20:35:31 +02:00
|
|
|
|
using Geekbot.net.Lib.IClients;
|
2017-04-12 21:49:04 +02:00
|
|
|
|
|
|
|
|
|
namespace Geekbot.net.Modules
|
|
|
|
|
{
|
|
|
|
|
public class UserInfo : ModuleBase
|
|
|
|
|
{
|
2017-04-18 11:00:38 +02:00
|
|
|
|
private readonly IRedisClient redis;
|
|
|
|
|
public UserInfo(IRedisClient redisClient)
|
|
|
|
|
{
|
|
|
|
|
redis = redisClient;
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-17 16:58:48 +02:00
|
|
|
|
[Alias("stats")]
|
2017-04-25 20:59:38 +02:00
|
|
|
|
[Command("user", RunMode = RunMode.Async), Summary("Get information about this user")]
|
2017-04-12 21:49:04 +02:00
|
|
|
|
public async Task User([Summary("The (optional) user to get info for")] IUser user = null)
|
|
|
|
|
{
|
|
|
|
|
var userInfo = user ?? Context.Message.Author;
|
|
|
|
|
|
|
|
|
|
var age = Math.Floor((DateTime.Now - userInfo.CreatedAt).TotalDays);
|
|
|
|
|
|
2017-04-17 16:58:48 +02:00
|
|
|
|
var key = Context.Guild.Id + "-" + userInfo.Id;
|
2017-04-18 11:00:38 +02:00
|
|
|
|
var messages = (int)redis.Client.StringGet(key + "-messages");
|
2017-04-21 22:51:30 +02:00
|
|
|
|
var level = LevelCalc.GetLevelAtExperience(messages);
|
2017-04-14 21:36:01 +02:00
|
|
|
|
|
2017-07-30 16:24:27 +02:00
|
|
|
|
var guildKey = Context.Guild.Id.ToString();
|
|
|
|
|
var guildMessages = (int)redis.Client.StringGet(guildKey + "-messages");
|
|
|
|
|
|
|
|
|
|
var percent = Math.Round((double)(100 * messages) / guildMessages, 2);
|
|
|
|
|
|
2017-04-17 23:58:43 +02:00
|
|
|
|
var eb = new EmbedBuilder();
|
|
|
|
|
eb.WithAuthor(new EmbedAuthorBuilder()
|
|
|
|
|
.WithIconUrl(userInfo.GetAvatarUrl())
|
|
|
|
|
.WithName(userInfo.Username));
|
2017-04-25 20:59:38 +02:00
|
|
|
|
|
2017-04-19 19:54:29 +02:00
|
|
|
|
eb.WithColor(new Color(221, 255, 119));
|
|
|
|
|
|
2017-04-17 23:58:43 +02:00
|
|
|
|
eb.AddField("Discordian Since", $"{userInfo.CreatedAt.Day}/{userInfo.CreatedAt.Month}/{userInfo.CreatedAt.Year} ({age} days)");
|
2017-04-19 19:23:22 +02:00
|
|
|
|
eb.AddInlineField("Level", level)
|
2017-07-30 16:24:27 +02:00
|
|
|
|
.AddInlineField("Messages Sent", messages)
|
|
|
|
|
.AddInlineField("Server Total", $"{percent}%");
|
2017-04-17 23:58:43 +02:00
|
|
|
|
|
2017-04-18 11:00:38 +02:00
|
|
|
|
var karma = redis.Client.StringGet(key + "-karma");
|
2017-04-17 23:58:43 +02:00
|
|
|
|
if (!karma.IsNullOrEmpty)
|
2017-04-17 16:58:48 +02:00
|
|
|
|
{
|
2017-07-30 16:24:27 +02:00
|
|
|
|
eb.AddInlineField("Karma", karma);
|
2017-04-17 16:58:48 +02:00
|
|
|
|
}
|
2017-04-22 23:41:15 +02:00
|
|
|
|
|
2017-04-24 21:42:43 +02:00
|
|
|
|
var correctRolls = redis.Client.StringGet($"{Context.Guild.Id}-{userInfo.Id}-correctRolls");
|
2017-04-22 23:41:15 +02:00
|
|
|
|
if (!correctRolls.IsNullOrEmpty)
|
|
|
|
|
{
|
2017-07-30 16:24:27 +02:00
|
|
|
|
eb.AddInlineField("Guessed Rolls", correctRolls);
|
2017-04-22 23:41:15 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-04-17 23:58:43 +02:00
|
|
|
|
await ReplyAsync("", false, eb.Build());
|
2017-04-12 21:49:04 +02:00
|
|
|
|
}
|
2017-04-13 00:03:03 +02:00
|
|
|
|
|
2017-04-21 22:51:30 +02:00
|
|
|
|
|
2017-04-12 21:49:04 +02:00
|
|
|
|
}
|
|
|
|
|
}
|