From 823b101b639d937a69d86f030376b09b280e23cf Mon Sep 17 00:00:00 2001 From: Ske Date: Sun, 23 Feb 2020 00:57:46 +0100 Subject: [PATCH] Restructure system timezone command --- PluralKit.Bot/Commands/SystemEdit.cs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/PluralKit.Bot/Commands/SystemEdit.cs b/PluralKit.Bot/Commands/SystemEdit.cs index e341d50d..5261328a 100644 --- a/PluralKit.Bot/Commands/SystemEdit.cs +++ b/PluralKit.Bot/Commands/SystemEdit.cs @@ -160,26 +160,33 @@ namespace PluralKit.Bot { if (ctx.System == null) throw Errors.NoSystemError; - var zoneStr = ctx.RemainderOrNull(); - if (zoneStr == null) + if (ctx.MatchFlag("c", "clear")) { ctx.System.UiTz = "UTC"; await _data.SaveSystem(ctx.System); await ctx.Reply($"{Emojis.Success} System time zone cleared."); return; } + + var zoneStr = ctx.RemainderOrNull(); + if (zoneStr == null) + { + await ctx.Reply( + $"Your current system time zone is set to **{ctx.System.UiTz}**. It is currently **{DateTimeFormats.ZonedDateTimeFormat.Format(SystemClock.Instance.GetCurrentInstant().InZone(ctx.System.Zone))}** in that time zone. To change your system time zone, type `pk;s tz `."); + return; + } var zone = await FindTimeZone(ctx, zoneStr); if (zone == null) throw Errors.InvalidTimeZone(zoneStr); var currentTime = SystemClock.Instance.GetCurrentInstant().InZone(zone); var msg = await ctx.Reply( - $"This will change the system time zone to {zone.Id}. The current time is {DateTimeFormats.ZonedDateTimeFormat.Format(currentTime)}. Is this correct?"); + $"This will change the system time zone to **{zone.Id}**. The current time is **{DateTimeFormats.ZonedDateTimeFormat.Format(currentTime)}**. Is this correct?"); if (!await ctx.PromptYesNo(msg)) throw Errors.TimezoneChangeCancelled; ctx.System.UiTz = zone.Id; await _data.SaveSystem(ctx.System); - await ctx.Reply($"System time zone changed to {zone.Id}."); + await ctx.Reply($"System time zone changed to **{zone.Id}**."); } public async Task SystemPrivacy(Context ctx)