1
0
mirror of https://gitlab.com/Deukhoofd/DeukBot4.git synced 2026-04-03 11:10:05 +00:00

Added Birthday to user info

This commit is contained in:
2018-10-08 18:53:04 +02:00
parent 55e920496a
commit fd0a58293c
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