Refactor data stores, merging the Store classes

This commit is contained in:
Ske
2019-10-26 19:45:30 +02:00
parent 1ab84b54dd
commit 6a73b3bdd6
21 changed files with 540 additions and 338 deletions

View File

@@ -7,10 +7,10 @@ namespace PluralKit.Bot.Commands
{
public class APICommands
{
private SystemStore _systems;
public APICommands(SystemStore systems)
private IDataStore _data;
public APICommands(IDataStore data)
{
_systems = systems;
_data = data;
}
public async Task GetToken(Context ctx)
@@ -34,7 +34,7 @@ namespace PluralKit.Bot.Commands
private async Task<string> MakeAndSetNewToken(PKSystem system)
{
system.Token = PluralKit.Utils.GenerateToken();
await _systems.Save(system);
await _data.SaveSystem(system);
return system.Token;
}

View File

@@ -8,11 +8,11 @@ namespace PluralKit.Bot.Commands
{
public class LinkCommands
{
private SystemStore _systems;
private IDataStore _data;
public LinkCommands(SystemStore systems)
public LinkCommands(IDataStore data)
{
_systems = systems;
_data = data;
}
public async Task LinkSystem(Context ctx)
@@ -20,15 +20,15 @@ namespace PluralKit.Bot.Commands
ctx.CheckSystem();
var account = await ctx.MatchUser() ?? throw new PKSyntaxError("You must pass an account to link with (either ID or @mention).");
var accountIds = await _systems.GetLinkedAccountIds(ctx.System);
var accountIds = await _data.GetSystemAccounts(ctx.System);
if (accountIds.Contains(account.Id)) throw Errors.AccountAlreadyLinked;
var existingAccount = await _systems.GetByAccount(account.Id);
var existingAccount = await _data.GetSystemByAccount(account.Id);
if (existingAccount != null) throw Errors.AccountInOtherSystem(existingAccount);
var msg = await ctx.Reply($"{account.Mention}, please confirm the link by clicking the {Emojis.Success} reaction on this message.");
if (!await ctx.PromptYesNo(msg, user: account)) throw Errors.MemberLinkCancelled;
await _systems.Link(ctx.System, account.Id);
await _data.AddAccount(ctx.System, account.Id);
await ctx.Reply($"{Emojis.Success} Account linked to system.");
}
@@ -42,7 +42,7 @@ namespace PluralKit.Bot.Commands
else
account = await ctx.MatchUser() ?? throw new PKSyntaxError("You must pass an account to link with (either ID or @mention).");
var accountIds = (await _systems.GetLinkedAccountIds(ctx.System)).ToList();
var accountIds = (await _data.GetSystemAccounts(ctx.System)).ToList();
if (!accountIds.Contains(account.Id)) throw Errors.AccountNotLinked;
if (accountIds.Count == 1) throw Errors.UnlinkingLastAccount;
@@ -50,7 +50,7 @@ namespace PluralKit.Bot.Commands
$"Are you sure you want to unlink {account.Mention} from your system?");
if (!await ctx.PromptYesNo(msg)) throw Errors.MemberUnlinkCancelled;
await _systems.Unlink(ctx.System, account.Id);
await _data.RemoveAccount(ctx.System, account.Id);
await ctx.Reply($"{Emojis.Success} Account unlinked.");
}
}

View File

@@ -11,16 +11,14 @@ namespace PluralKit.Bot.Commands
{
public class MemberCommands
{
private SystemStore _systems;
private MemberStore _members;
private IDataStore _data;
private EmbedService _embeds;
private ProxyCacheService _proxyCache;
public MemberCommands(SystemStore systems, MemberStore members, EmbedService embeds, ProxyCacheService proxyCache)
public MemberCommands(IDataStore data, EmbedService embeds, ProxyCacheService proxyCache)
{
_systems = systems;
_members = members;
_data = data;
_embeds = embeds;
_proxyCache = proxyCache;
}
@@ -39,19 +37,19 @@ namespace PluralKit.Bot.Commands
}
// Warn if there's already a member by this name
var existingMember = await _members.GetByName(ctx.System, memberName);
var existingMember = await _data.GetMemberByName(ctx.System, memberName);
if (existingMember != null) {
var msg = await ctx.Reply($"{Emojis.Warn} You already have a member in your system with the name \"{existingMember.Name.SanitizeMentions()}\" (with ID `{existingMember.Hid}`). Do you want to create another member with the same name?");
if (!await ctx.PromptYesNo(msg)) throw new PKError("Member creation cancelled.");
}
// Enforce per-system member limit
var memberCount = await _members.MemberCount(ctx.System);
var memberCount = await _data.GetSystemMemberCount(ctx.System);
if (memberCount >= Limits.MaxMemberCount)
throw Errors.MemberLimitReachedError;
// Create the member
var member = await _members.Create(ctx.System, memberName);
var member = await _data.CreateMember(ctx.System, memberName);
memberCount++;
// Send confirmation and space hint
@@ -83,7 +81,7 @@ namespace PluralKit.Bot.Commands
}
// Warn if there's already a member by this name
var existingMember = await _members.GetByName(ctx.System, newName);
var existingMember = await _data.GetMemberByName(ctx.System, newName);
if (existingMember != null) {
var msg = await ctx.Reply($"{Emojis.Warn} You already have a member in your system with the name \"{existingMember.Name.SanitizeMentions()}\" (`{existingMember.Hid}`). Do you want to rename this member to that name too?");
if (!await ctx.PromptYesNo(msg)) throw new PKError("Member renaming cancelled.");
@@ -91,7 +89,7 @@ namespace PluralKit.Bot.Commands
// Rename the member
target.Name = newName;
await _members.Save(target);
await _data.SaveMember(target);
await ctx.Reply($"{Emojis.Success} Member renamed.");
if (newName.Contains(" ")) await ctx.Reply($"{Emojis.Note} Note that this member's name now contains spaces. You will need to surround it with \"double quotes\" when using commands referring to it.");
@@ -108,7 +106,7 @@ namespace PluralKit.Bot.Commands
if (description.IsLongerThan(Limits.MaxDescriptionLength)) throw Errors.DescriptionTooLongError(description.Length);
target.Description = description;
await _members.Save(target);
await _data.SaveMember(target);
await ctx.Reply($"{Emojis.Success} Member description {(description == null ? "cleared" : "changed")}.");
}
@@ -121,7 +119,7 @@ namespace PluralKit.Bot.Commands
if (pronouns.IsLongerThan(Limits.MaxPronounsLength)) throw Errors.MemberPronounsTooLongError(pronouns.Length);
target.Pronouns = pronouns;
await _members.Save(target);
await _data.SaveMember(target);
await ctx.Reply($"{Emojis.Success} Member pronouns {(pronouns == null ? "cleared" : "changed")}.");
}
@@ -139,7 +137,7 @@ namespace PluralKit.Bot.Commands
}
target.Color = color;
await _members.Save(target);
await _data.SaveMember(target);
await ctx.Reply($"{Emojis.Success} Member color {(color == null ? "cleared" : "changed")}.");
}
@@ -158,7 +156,7 @@ namespace PluralKit.Bot.Commands
}
target.Birthday = date;
await _members.Save(target);
await _data.SaveMember(target);
await ctx.Reply($"{Emojis.Success} Member birthdate {(date == null ? "cleared" : $"changed to {target.BirthdayString}")}.");
}
@@ -175,7 +173,7 @@ namespace PluralKit.Bot.Commands
// Just reset and send OK message
target.Prefix = null;
target.Suffix = null;
await _members.Save(target);
await _data.SaveMember(target);
await ctx.Reply($"{Emojis.Success} Member proxy tags cleared.");
return;
}
@@ -188,7 +186,7 @@ namespace PluralKit.Bot.Commands
// If the prefix/suffix is empty, use "null" instead (for DB)
target.Prefix = prefixAndSuffix[0].Length > 0 ? prefixAndSuffix[0] : null;
target.Suffix = prefixAndSuffix[1].Length > 0 ? prefixAndSuffix[1] : null;
await _members.Save(target);
await _data.SaveMember(target);
await ctx.Reply($"{Emojis.Success} Member proxy tags changed to `{target.ProxyString.SanitizeMentions()}`. Try proxying now!");
await _proxyCache.InvalidateResultsForSystem(ctx.System);
@@ -201,7 +199,7 @@ namespace PluralKit.Bot.Commands
await ctx.Reply($"{Emojis.Warn} Are you sure you want to delete \"{target.Name.SanitizeMentions()}\"? If so, reply to this message with the member's ID (`{target.Hid}`). __***This cannot be undone!***__");
if (!await ctx.ConfirmWithReply(target.Hid)) throw Errors.MemberDeleteCancelled;
await _members.Delete(target);
await _data.DeleteMember(target);
await ctx.Reply($"{Emojis.Success} Member deleted.");
await _proxyCache.InvalidateResultsForSystem(ctx.System);
@@ -217,7 +215,7 @@ namespace PluralKit.Bot.Commands
if (user.AvatarId == null) throw Errors.UserHasNoAvatar;
target.AvatarUrl = user.GetAvatarUrl(ImageFormat.Png, size: 256);
await _members.Save(target);
await _data.SaveMember(target);
var embed = new EmbedBuilder().WithImageUrl(target.AvatarUrl).Build();
await ctx.Reply(
@@ -228,7 +226,7 @@ namespace PluralKit.Bot.Commands
{
await Utils.VerifyAvatarOrThrow(url);
target.AvatarUrl = url;
await _members.Save(target);
await _data.SaveMember(target);
var embed = new EmbedBuilder().WithImageUrl(url).Build();
await ctx.Reply($"{Emojis.Success} Member avatar changed.", embed: embed);
@@ -237,14 +235,14 @@ namespace PluralKit.Bot.Commands
{
await Utils.VerifyAvatarOrThrow(attachment.Url);
target.AvatarUrl = attachment.Url;
await _members.Save(target);
await _data.SaveMember(target);
await ctx.Reply($"{Emojis.Success} Member avatar changed to attached image. Please note that if you delete the message containing the attachment, the avatar will stop working.");
}
else
{
target.AvatarUrl = null;
await _members.Save(target);
await _data.SaveMember(target);
await ctx.Reply($"{Emojis.Success} Member avatar cleared.");
}
@@ -262,7 +260,7 @@ namespace PluralKit.Bot.Commands
throw Errors.DisplayNameTooLong(newDisplayName, ctx.System.MaxMemberNameLength);
target.DisplayName = newDisplayName;
await _members.Save(target);
await _data.SaveMember(target);
var successStr = $"{Emojis.Success} ";
if (newDisplayName != null)
@@ -288,7 +286,7 @@ namespace PluralKit.Bot.Commands
public async Task ViewMember(Context ctx, PKMember target)
{
var system = await _systems.GetById(target.System);
var system = await _data.GetSystemById(target.System);
await ctx.Reply(embed: await _embeds.CreateMemberEmbed(system, target));
}
}

View File

@@ -9,14 +9,14 @@ namespace PluralKit.Bot.Commands
public class ModCommands
{
private LogChannelService _logChannels;
private MessageStore _messages;
private IDataStore _data;
private EmbedService _embeds;
public ModCommands(LogChannelService logChannels, MessageStore messages, EmbedService embeds)
public ModCommands(LogChannelService logChannels, IDataStore data, EmbedService embeds)
{
_logChannels = logChannels;
_messages = messages;
_data = data;
_embeds = embeds;
}
@@ -47,7 +47,7 @@ namespace PluralKit.Bot.Commands
messageId = ulong.Parse(match.Groups[1].Value);
else throw new PKSyntaxError($"Could not parse `{word}` as a message ID or link.");
var message = await _messages.Get(messageId);
var message = await _data.GetMessage(messageId);
if (message == null) throw Errors.MessageNotFound(messageId);
await ctx.Reply(embed: await _embeds.CreateMessageInfoEmbed(message));

View File

@@ -12,11 +12,11 @@ namespace PluralKit.Bot.Commands
{
public class SwitchCommands
{
private SwitchStore _switches;
private IDataStore _data;
public SwitchCommands(SwitchStore switches)
public SwitchCommands(IDataStore data)
{
_switches = switches;
_data = data;
}
public async Task Switch(Context ctx)
@@ -55,16 +55,16 @@ namespace PluralKit.Bot.Commands
if (members.Select(m => m.Id).Distinct().Count() != members.Count) throw Errors.DuplicateSwitchMembers;
// Find the last switch and its members if applicable
var lastSwitch = await _switches.GetLatestSwitch(ctx.System);
var lastSwitch = await _data.GetLatestSwitch(ctx.System);
if (lastSwitch != null)
{
var lastSwitchMembers = await _switches.GetSwitchMembers(lastSwitch);
var lastSwitchMembers = await _data.GetSwitchMembers(lastSwitch);
// Make sure the requested switch isn't identical to the last one
if (lastSwitchMembers.Select(m => m.Id).SequenceEqual(members.Select(m => m.Id)))
throw Errors.SameSwitch(members);
}
await _switches.RegisterSwitch(ctx.System, members);
await _data.AddSwitch(ctx.System, members);
if (members.Count == 0)
await ctx.Reply($"{Emojis.Success} Switch-out registered.");
@@ -86,7 +86,7 @@ namespace PluralKit.Bot.Commands
if (time.ToInstant() > SystemClock.Instance.GetCurrentInstant()) throw Errors.SwitchTimeInFuture;
// Fetch the last two switches for the system to do bounds checking on
var lastTwoSwitches = (await _switches.GetSwitches(ctx.System, 2)).ToArray();
var lastTwoSwitches = (await _data.GetSwitches(ctx.System, 2)).ToArray();
// If we don't have a switch to move, don't bother
if (lastTwoSwitches.Length == 0) throw Errors.NoRegisteredSwitches;
@@ -100,7 +100,7 @@ namespace PluralKit.Bot.Commands
// Now we can actually do the move, yay!
// But, we do a prompt to confirm.
var lastSwitchMembers = await _switches.GetSwitchMembers(lastTwoSwitches[0]);
var lastSwitchMembers = await _data.GetSwitchMembers(lastTwoSwitches[0]);
var lastSwitchMemberStr = string.Join(", ", lastSwitchMembers.Select(m => m.Name));
var lastSwitchTimeStr = Formats.ZonedDateTimeFormat.Format(lastTwoSwitches[0].Timestamp.InZone(ctx.System.Zone));
var lastSwitchDeltaStr = Formats.DurationFormat.Format(SystemClock.Instance.GetCurrentInstant() - lastTwoSwitches[0].Timestamp);
@@ -112,7 +112,7 @@ namespace PluralKit.Bot.Commands
if (!await ctx.PromptYesNo(msg)) throw Errors.SwitchMoveCancelled;
// aaaand *now* we do the move
await _switches.MoveSwitch(lastTwoSwitches[0], time.ToInstant());
await _data.MoveSwitch(lastTwoSwitches[0], time.ToInstant());
await ctx.Reply($"{Emojis.Success} Switch moved.");
}
@@ -121,10 +121,10 @@ namespace PluralKit.Bot.Commands
ctx.CheckSystem();
// Fetch the last two switches for the system to do bounds checking on
var lastTwoSwitches = (await _switches.GetSwitches(ctx.System, 2)).ToArray();
var lastTwoSwitches = (await _data.GetSwitches(ctx.System, 2)).ToArray();
if (lastTwoSwitches.Length == 0) throw Errors.NoRegisteredSwitches;
var lastSwitchMembers = await _switches.GetSwitchMembers(lastTwoSwitches[0]);
var lastSwitchMembers = await _data.GetSwitchMembers(lastTwoSwitches[0]);
var lastSwitchMemberStr = string.Join(", ", lastSwitchMembers.Select(m => m.Name));
var lastSwitchDeltaStr = Formats.DurationFormat.Format(SystemClock.Instance.GetCurrentInstant() - lastTwoSwitches[0].Timestamp);
@@ -136,7 +136,7 @@ namespace PluralKit.Bot.Commands
}
else
{
var secondSwitchMembers = await _switches.GetSwitchMembers(lastTwoSwitches[1]);
var secondSwitchMembers = await _data.GetSwitchMembers(lastTwoSwitches[1]);
var secondSwitchMemberStr = string.Join(", ", secondSwitchMembers.Select(m => m.Name));
var secondSwitchDeltaStr = Formats.DurationFormat.Format(SystemClock.Instance.GetCurrentInstant() - lastTwoSwitches[1].Timestamp);
msg = await ctx.Reply(
@@ -144,7 +144,7 @@ namespace PluralKit.Bot.Commands
}
if (!await ctx.PromptYesNo(msg)) throw Errors.SwitchDeleteCancelled;
await _switches.DeleteSwitch(lastTwoSwitches[0]);
await _data.DeleteSwitch(lastTwoSwitches[0]);
await ctx.Reply($"{Emojis.Success} Switch deleted.");
}

View File

@@ -14,21 +14,16 @@ namespace PluralKit.Bot.Commands
{
public class SystemCommands
{
private SystemStore _systems;
private MemberStore _members;
private SwitchStore _switches;
private IDataStore _data;
private EmbedService _embeds;
private ProxyCacheService _proxyCache;
public SystemCommands(SystemStore systems, MemberStore members, SwitchStore switches, EmbedService embeds, ProxyCacheService proxyCache)
public SystemCommands(EmbedService embeds, ProxyCacheService proxyCache, IDataStore data)
{
_systems = systems;
_members = members;
_switches = switches;
_embeds = embeds;
_proxyCache = proxyCache;
_data = data;
}
public async Task Query(Context ctx, PKSystem system) {
@@ -41,8 +36,8 @@ namespace PluralKit.Bot.Commands
{
ctx.CheckNoSystem();
var system = await _systems.Create(ctx.RemainderOrNull());
await _systems.Link(system, ctx.Author.Id);
var system = await _data.CreateSystem(ctx.RemainderOrNull());
await _data.AddAccount(system, ctx.Author.Id);
await ctx.Reply($"{Emojis.Success} Your system has been created. Type `pk;system` to view it, and type `pk;help` for more information about commands you can use now.");
}
@@ -54,7 +49,7 @@ namespace PluralKit.Bot.Commands
if (newSystemName != null && newSystemName.Length > Limits.MaxSystemNameLength) throw Errors.SystemNameTooLongError(newSystemName.Length);
ctx.System.Name = newSystemName;
await _systems.Save(ctx.System);
await _data.SaveSystem(ctx.System);
await ctx.Reply($"{Emojis.Success} System name {(newSystemName != null ? "changed" : "cleared")}.");
}
@@ -65,7 +60,7 @@ namespace PluralKit.Bot.Commands
if (newDescription != null && newDescription.Length > Limits.MaxDescriptionLength) throw Errors.DescriptionTooLongError(newDescription.Length);
ctx.System.Description = newDescription;
await _systems.Save(ctx.System);
await _data.SaveSystem(ctx.System);
await ctx.Reply($"{Emojis.Success} System description {(newDescription != null ? "changed" : "cleared")}.");
}
@@ -80,17 +75,18 @@ namespace PluralKit.Bot.Commands
{
if (newTag.Length > Limits.MaxSystemTagLength) throw Errors.SystemNameTooLongError(newTag.Length);
// Check unproxyable messages *after* changing the tag (so it's seen in the method) but *before* we save to DB (so we can cancel)
var unproxyableMembers = await _members.GetUnproxyableMembers(ctx.System);
if (unproxyableMembers.Count > 0)
{
var msg = await ctx.Reply(
$"{Emojis.Warn} Changing your system tag to '{newTag.SanitizeMentions()}' will result in the following members being unproxyable, since the tag would bring their name over {Limits.MaxProxyNameLength} characters:\n**{string.Join(", ", unproxyableMembers.Select((m) => m.Name.SanitizeMentions()))}**\nDo you want to continue anyway?");
if (!await ctx.PromptYesNo(msg)) throw new PKError("Tag change cancelled.");
}
// TODO: The proxy name limit is long enough now that this probably doesn't matter much.
// // Check unproxyable messages *after* changing the tag (so it's seen in the method) but *before* we save to DB (so we can cancel)
// var unproxyableMembers = await _data.GetUnproxyableMembers(ctx.System);
// if (unproxyableMembers.Count > 0)
// {
// var msg = await ctx.Reply(
// $"{Emojis.Warn} Changing your system tag to '{newTag.SanitizeMentions()}' will result in the following members being unproxyable, since the tag would bring their name over {Limits.MaxProxyNameLength} characters:\n**{string.Join(", ", unproxyableMembers.Select((m) => m.Name.SanitizeMentions()))}**\nDo you want to continue anyway?");
// if (!await ctx.PromptYesNo(msg)) throw new PKError("Tag change cancelled.");
// }
}
await _systems.Save(ctx.System);
await _data.SaveSystem(ctx.System);
await ctx.Reply($"{Emojis.Success} System tag {(newTag != null ? "changed" : "cleared")}.");
await _proxyCache.InvalidateResultsForSystem(ctx.System);
@@ -105,7 +101,7 @@ namespace PluralKit.Bot.Commands
{
if (member.AvatarId == null) throw Errors.UserHasNoAvatar;
ctx.System.AvatarUrl = member.GetAvatarUrl(ImageFormat.Png, size: 256);
await _systems.Save(ctx.System);
await _data.SaveSystem(ctx.System);
var embed = new EmbedBuilder().WithImageUrl(ctx.System.AvatarUrl).Build();
await ctx.Reply(
@@ -117,7 +113,7 @@ namespace PluralKit.Bot.Commands
if (url != null) await ctx.BusyIndicator(() => Utils.VerifyAvatarOrThrow(url));
ctx.System.AvatarUrl = url;
await _systems.Save(ctx.System);
await _data.SaveSystem(ctx.System);
var embed = url != null ? new EmbedBuilder().WithImageUrl(url).Build() : null;
await ctx.Reply($"{Emojis.Success} System avatar {(url == null ? "cleared" : "changed")}.", embed: embed);
@@ -133,7 +129,7 @@ namespace PluralKit.Bot.Commands
var reply = await ctx.AwaitMessage(ctx.Channel, ctx.Author, timeout: TimeSpan.FromMinutes(1));
if (reply.Content != ctx.System.Hid) throw new PKError($"System deletion cancelled. Note that you must reply with your system ID (`{ctx.System.Hid}`) *verbatim*.");
await _systems.Delete(ctx.System);
await _data.DeleteSystem(ctx.System);
await ctx.Reply($"{Emojis.Success} System deleted.");
await _proxyCache.InvalidateResultsForSystem(ctx.System);
@@ -142,7 +138,7 @@ namespace PluralKit.Bot.Commands
public async Task MemberShortList(Context ctx, PKSystem system) {
if (system == null) throw Errors.NoSystemError;
var members = await _members.GetBySystem(system);
var members = await _data.GetSystemMembers(system);
var embedTitle = system.Name != null ? $"Members of {system.Name.SanitizeMentions()} (`{system.Hid}`)" : $"Members of `{system.Hid}`";
await ctx.Paginate<PKMember>(
members.OrderBy(m => m.Name.ToLower()).ToList(),
@@ -158,7 +154,7 @@ namespace PluralKit.Bot.Commands
public async Task MemberLongList(Context ctx, PKSystem system) {
if (system == null) throw Errors.NoSystemError;
var members = await _members.GetBySystem(system);
var members = await _data.GetSystemMembers(system);
var embedTitle = system.Name != null ? $"Members of {system.Name} (`{system.Hid}`)" : $"Members of `{system.Hid}`";
await ctx.Paginate<PKMember>(
members.OrderBy(m => m.Name.ToLower()).ToList(),
@@ -181,7 +177,7 @@ namespace PluralKit.Bot.Commands
{
if (system == null) throw Errors.NoSystemError;
var sw = await _switches.GetLatestSwitch(system);
var sw = await _data.GetLatestSwitch(system);
if (sw == null) throw Errors.NoRegisteredSwitches;
await ctx.Reply(embed: await _embeds.CreateFronterEmbed(sw, system.Zone));
@@ -191,7 +187,7 @@ namespace PluralKit.Bot.Commands
{
if (system == null) throw Errors.NoSystemError;
var sws = (await _switches.GetSwitches(system, 10)).ToList();
var sws = (await _data.GetSwitches(system, 10)).ToList();
if (sws.Count == 0) throw Errors.NoRegisteredSwitches;
await ctx.Reply(embed: await _embeds.CreateFrontHistoryEmbed(sws, system.Zone));
@@ -209,7 +205,7 @@ namespace PluralKit.Bot.Commands
if (rangeStart == null) throw Errors.InvalidDateTime(durationStr);
if (rangeStart.Value.ToInstant() > now) throw Errors.FrontPercentTimeInFuture;
var frontpercent = await _switches.GetPerMemberSwitchDuration(system, rangeStart.Value.ToInstant(), now);
var frontpercent = await _data.GetFrontBreakdown(system, rangeStart.Value.ToInstant(), now);
await ctx.Reply(embed: await _embeds.CreateFrontPercentEmbed(frontpercent, system.Zone));
}
@@ -221,7 +217,7 @@ namespace PluralKit.Bot.Commands
if (zoneStr == null)
{
ctx.System.UiTz = "UTC";
await _systems.Save(ctx.System);
await _data.SaveSystem(ctx.System);
await ctx.Reply($"{Emojis.Success} System time zone cleared.");
return;
}
@@ -234,7 +230,7 @@ namespace PluralKit.Bot.Commands
$"This will change the system time zone to {zone.Id}. The current time is {Formats.ZonedDateTimeFormat.Format(currentTime)}. Is this correct?");
if (!await ctx.PromptYesNo(msg)) throw Errors.TimezoneChangeCancelled;
ctx.System.UiTz = zone.Id;
await _systems.Save(ctx.System);
await _data.SaveSystem(ctx.System);
await ctx.Reply($"System time zone changed to {zone.Id}.");
}