Added Birthday to user info
This commit is contained in:
parent
55e920496a
commit
fd0a58293c
|
@ -9,6 +9,23 @@ namespace DeukBot4.Database
|
||||||
{
|
{
|
||||||
private static ConnectionMultiplexer Redis => ReminderHandler.Redis;
|
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)
|
public static async Task AddBirthday(DateTime birthday, ulong server, ulong user)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|
|
@ -230,6 +230,12 @@ namespace DeukBot4.MessageHandlers.CommandHandler
|
||||||
if (guildUser.JoinedAt.HasValue)
|
if (guildUser.JoinedAt.HasValue)
|
||||||
eb.AddField("Joined Server At", guildUser.JoinedAt.Value.ToString("D"), true);
|
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 roles = guildUser.RoleIds;
|
||||||
var sb = new StringBuilder();
|
var sb = new StringBuilder();
|
||||||
foreach (var roleId in roles)
|
foreach (var roleId in roles)
|
||||||
|
|
Loading…
Reference in New Issue