feat: add "today" argument to pk;m birthday (#398)

This commit is contained in:
Spectralitree
2021-10-29 17:44:51 -04:00
committed by spiral
parent f897ce5a45
commit e0c43a9af7
3 changed files with 10 additions and 3 deletions

View File

@@ -6,6 +6,7 @@ using System.Net.Http;
using Myriad.Builders;
using NodaTime;
using NodaTime.Extensions;
using PluralKit.Core;
@@ -288,7 +289,13 @@ namespace PluralKit.Bot
ctx.CheckOwnMember(target);
var birthdayStr = ctx.RemainderOrNull();
var birthday = DateUtils.ParseDate(birthdayStr, true);
LocalDate? birthday;
if (birthdayStr == "today" || birthdayStr == "now")
birthday = SystemClock.Instance.InZone(ctx.System.Zone).GetCurrentDate();
else
birthday = DateUtils.ParseDate(birthdayStr, true);
if (birthday == null) throw Errors.BirthdayParseError(birthdayStr);
var patch = new MemberPatch { Birthday = Partial<LocalDate?>.Present(birthday) };