Restructure system timezone command
This commit is contained in:
parent
4df3be8c3a
commit
823b101b63
@ -160,26 +160,33 @@ namespace PluralKit.Bot
|
|||||||
{
|
{
|
||||||
if (ctx.System == null) throw Errors.NoSystemError;
|
if (ctx.System == null) throw Errors.NoSystemError;
|
||||||
|
|
||||||
var zoneStr = ctx.RemainderOrNull();
|
if (ctx.MatchFlag("c", "clear"))
|
||||||
if (zoneStr == null)
|
|
||||||
{
|
{
|
||||||
ctx.System.UiTz = "UTC";
|
ctx.System.UiTz = "UTC";
|
||||||
await _data.SaveSystem(ctx.System);
|
await _data.SaveSystem(ctx.System);
|
||||||
await ctx.Reply($"{Emojis.Success} System time zone cleared.");
|
await ctx.Reply($"{Emojis.Success} System time zone cleared.");
|
||||||
return;
|
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 <zone>`.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var zone = await FindTimeZone(ctx, zoneStr);
|
var zone = await FindTimeZone(ctx, zoneStr);
|
||||||
if (zone == null) throw Errors.InvalidTimeZone(zoneStr);
|
if (zone == null) throw Errors.InvalidTimeZone(zoneStr);
|
||||||
|
|
||||||
var currentTime = SystemClock.Instance.GetCurrentInstant().InZone(zone);
|
var currentTime = SystemClock.Instance.GetCurrentInstant().InZone(zone);
|
||||||
var msg = await ctx.Reply(
|
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;
|
if (!await ctx.PromptYesNo(msg)) throw Errors.TimezoneChangeCancelled;
|
||||||
ctx.System.UiTz = zone.Id;
|
ctx.System.UiTz = zone.Id;
|
||||||
await _data.SaveSystem(ctx.System);
|
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)
|
public async Task SystemPrivacy(Context ctx)
|
||||||
|
Loading…
Reference in New Issue
Block a user