From e0c43a9af73c35c64295030ae1e3002bb4b462ac Mon Sep 17 00:00:00 2001 From: Spectralitree <72747870+Spectralitree@users.noreply.github.com> Date: Fri, 29 Oct 2021 17:44:51 -0400 Subject: [PATCH] feat: add "today" argument to pk;m birthday (#398) --- PluralKit.Bot/Commands/CommandTree.cs | 2 +- PluralKit.Bot/Commands/MemberEdit.cs | 9 ++++++++- docs/content/command-list.md | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/PluralKit.Bot/Commands/CommandTree.cs b/PluralKit.Bot/Commands/CommandTree.cs index e96d1316..5c016def 100644 --- a/PluralKit.Bot/Commands/CommandTree.cs +++ b/PluralKit.Bot/Commands/CommandTree.cs @@ -37,7 +37,7 @@ namespace PluralKit.Bot public static Command MemberDesc = new Command("member description", "member description [description]", "Changes a member's description"); public static Command MemberPronouns = new Command("member pronouns", "member pronouns [pronouns]", "Changes a member's pronouns"); public static Command MemberColor = new Command("member color", "member color [color]", "Changes a member's color"); - public static Command MemberBirthday = new Command("member birthday", "member birthday [birthday]", "Changes a member's birthday"); + public static Command MemberBirthday = new Command("member birthday", "member birthday [birthday|today]", "Changes a member's birthday"); public static Command MemberProxy = new Command("member proxy", "member proxy [add|remove] [example proxy]", "Changes, adds, or removes a member's proxy tags"); public static Command MemberDelete = new Command("member delete", "member delete", "Deletes a member"); public static Command MemberBannerImage = new Command("member banner", "member banner [url]", "Set the member's banner image"); diff --git a/PluralKit.Bot/Commands/MemberEdit.cs b/PluralKit.Bot/Commands/MemberEdit.cs index 6e987e69..1a5e8053 100644 --- a/PluralKit.Bot/Commands/MemberEdit.cs +++ b/PluralKit.Bot/Commands/MemberEdit.cs @@ -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.Present(birthday) }; diff --git a/docs/content/command-list.md b/docs/content/command-list.md index bea27c4e..43cc999b 100644 --- a/docs/content/command-list.md +++ b/docs/content/command-list.md @@ -77,7 +77,7 @@ Some arguments indicate the use of specific Discord features. These include: - `pk;member keepproxy [on|off]` - Sets whether to include a member's proxy tags in the proxied message. - `pk;member pronouns [pronouns]` - Changes the pronouns of a member. - `pk;member color [color]` - Changes the color of a member. -- `pk;member birthdate [birthdate]` - Changes the birthday of a member. +- `pk;member birthdate [birthdate|today]` - Changes the birthday of a member. - `pk;member delete` - Deletes a member. ## Group commands