Added Birthday to user info

This commit is contained in:
Deukhoofd 2018-10-08 18:53:04 +02:00
parent 55e920496a
commit fd0a58293c
No known key found for this signature in database
GPG Key ID: B4C087AC81641654
2 changed files with 23 additions and 0 deletions

View File

@ -9,6 +9,23 @@ namespace DeukBot4.Database
{
private static ConnectionMultiplexer Redis => ReminderHandler.Redis;
public static async Task<DateTime?> GetBirthday(ulong server, ulong user)
{
var db = Redis.GetDatabase();
var exists = db.HashGet("birthdays", (RedisValue) $"{server}-{user}");
if (exists.HasValue)
{
var bdayEntries = db.HashGetAll(exists.ToString());
DateTime bday = DateTime.MinValue;
foreach (var bdayEntry in bdayEntries)
{
if (bdayEntry.Name == "birthday") bday = DateTime.FromBinary(long.Parse(bdayEntry.Value));
}
return bday;
}
return null;
}
public static async Task AddBirthday(DateTime birthday, ulong server, ulong user)
{
try

View File

@ -230,6 +230,12 @@ namespace DeukBot4.MessageHandlers.CommandHandler
if (guildUser.JoinedAt.HasValue)
eb.AddField("Joined Server At", guildUser.JoinedAt.Value.ToString("D"), true);
var bday = await BirthdayHandler.GetBirthday(guildUser.GuildId, guildUser.Id);
if (bday.HasValue)
{
eb.AddField("Birthday", bday.Value.ToString("D"), true);
}
var roles = guildUser.RoleIds;
var sb = new StringBuilder();
foreach (var roleId in roles)