diff --git a/Myriad/Rest/Types/Requests/MessageEditRequest.cs b/Myriad/Rest/Types/Requests/MessageEditRequest.cs index bf217c83..3e74f7f9 100644 --- a/Myriad/Rest/Types/Requests/MessageEditRequest.cs +++ b/Myriad/Rest/Types/Requests/MessageEditRequest.cs @@ -18,5 +18,8 @@ namespace Myriad.Rest.Types.Requests [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] public Optional AllowedMentions { get; init; } + + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] + public Optional Components { get; init; } } } \ No newline at end of file diff --git a/PluralKit.Bot/Commands/Groups.cs b/PluralKit.Bot/Commands/Groups.cs index e4c5aa68..e82c9f41 100644 --- a/PluralKit.Bot/Commands/Groups.cs +++ b/PluralKit.Bot/Commands/Groups.cs @@ -51,7 +51,7 @@ namespace PluralKit.Bot var existingGroup = await _repo.GetGroupByName(conn, ctx.System.Id, groupName); if (existingGroup != null) { var msg = $"{Emojis.Warn} You already have a group in your system with the name \"{existingGroup.Name}\" (with ID `{existingGroup.Hid}`). Do you want to create another group with the same name?"; - if (!await ctx.PromptYesNo(msg)) + if (!await ctx.PromptYesNo(msg, "Create")) throw new PKError("Group creation cancelled."); } @@ -81,7 +81,7 @@ namespace PluralKit.Bot var existingGroup = await _repo.GetGroupByName(conn, ctx.System.Id, newName); if (existingGroup != null && existingGroup.Id != target.Id) { var msg = $"{Emojis.Warn} You already have a group in your system with the name \"{existingGroup.Name}\" (with ID `{existingGroup.Hid}`). Do you want to rename this member to that name too?"; - if (!await ctx.PromptYesNo(msg)) + if (!await ctx.PromptYesNo(msg, "Rename")) throw new PKError("Group creation cancelled."); } diff --git a/PluralKit.Bot/Commands/ImportExport.cs b/PluralKit.Bot/Commands/ImportExport.cs index a4da57ba..17d757d5 100644 --- a/PluralKit.Bot/Commands/ImportExport.cs +++ b/PluralKit.Bot/Commands/ImportExport.cs @@ -73,7 +73,7 @@ namespace PluralKit.Bot if (data.LinkedAccounts != null && !data.LinkedAccounts.Contains(ctx.Author.Id)) { var msg = $"{Emojis.Warn} You seem to importing a system profile belonging to another account. Are you sure you want to proceed?"; - if (!await ctx.PromptYesNo(msg)) throw Errors.ImportCancelled; + if (!await ctx.PromptYesNo(msg, "Import")) throw Errors.ImportCancelled; } // If passed system is null, it'll create a new one @@ -120,7 +120,7 @@ namespace PluralKit.Bot issueStr += "\n- PluralKit does not support per-member system tags. Since you had multiple members with distinct tags, those tags will be applied to the members' *display names*/nicknames instead."; var msg = $"{issueStr}\n\nDo you want to proceed with the import?"; - if (!await ctx.PromptYesNo(msg)) + if (!await ctx.PromptYesNo(msg, "Proceed")) throw Errors.ImportCancelled; } @@ -163,4 +163,4 @@ namespace PluralKit.Bot } } } -} \ No newline at end of file +} diff --git a/PluralKit.Bot/Commands/Member.cs b/PluralKit.Bot/Commands/Member.cs index 0ebf72c6..eb88e589 100644 --- a/PluralKit.Bot/Commands/Member.cs +++ b/PluralKit.Bot/Commands/Member.cs @@ -41,7 +41,7 @@ namespace PluralKit.Bot var existingMember = await _db.Execute(c => _repo.GetMemberByName(c, ctx.System.Id, memberName)); if (existingMember != null) { var msg = $"{Emojis.Warn} You already have a member in your system with the name \"{existingMember.NameFor(ctx)}\" (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."); + if (!await ctx.PromptYesNo(msg, "Create")) throw new PKError("Member creation cancelled."); } await using var conn = await _db.Obtain(); diff --git a/PluralKit.Bot/Commands/MemberEdit.cs b/PluralKit.Bot/Commands/MemberEdit.cs index b643ba88..76ade3ba 100644 --- a/PluralKit.Bot/Commands/MemberEdit.cs +++ b/PluralKit.Bot/Commands/MemberEdit.cs @@ -35,7 +35,7 @@ namespace PluralKit.Bot if (existingMember != null && existingMember.Id != target.Id) { var msg = $"{Emojis.Warn} You already have a member in your system with the name \"{existingMember.NameFor(ctx)}\" (`{existingMember.Hid}`). Do you want to rename this member to that name too?"; - if (!await ctx.PromptYesNo(msg)) throw new PKError("Member renaming cancelled."); + if (!await ctx.PromptYesNo(msg, "Rename")) throw new PKError("Member renaming cancelled."); } // Rename the member diff --git a/PluralKit.Bot/Commands/MemberProxy.cs b/PluralKit.Bot/Commands/MemberProxy.cs index ab8ff34e..f1efb38a 100644 --- a/PluralKit.Bot/Commands/MemberProxy.cs +++ b/PluralKit.Bot/Commands/MemberProxy.cs @@ -42,7 +42,7 @@ namespace PluralKit.Bot var conflictList = conflicts.Select(m => $"- **{m.NameFor(ctx)}**"); var msg = $"{Emojis.Warn} The following members have conflicting proxy tags:\n{string.Join('\n', conflictList)}\nDo you want to proceed anyway?"; - return await ctx.PromptYesNo(msg); + return await ctx.PromptYesNo(msg, "Proceed"); } // "Sub"command: clear flag @@ -52,7 +52,7 @@ namespace PluralKit.Bot if (target.ProxyTags.Count > 1) { var msg = $"{Emojis.Warn} You already have multiple proxy tags set: {target.ProxyTagsString()}\nDo you want to clear them all?"; - if (!await ctx.PromptYesNo(msg)) + if (!await ctx.PromptYesNo(msg, "Clear")) throw Errors.GenericCancelled(); } @@ -117,7 +117,7 @@ namespace PluralKit.Bot if (target.ProxyTags.Count > 1) { var msg = $"This member already has more than one proxy tag set: {target.ProxyTagsString()}\nDo you want to replace them?"; - if (!await ctx.PromptYesNo(msg)) + if (!await ctx.PromptYesNo(msg, "Replace")) throw Errors.GenericCancelled(); } diff --git a/PluralKit.Bot/Commands/Switch.cs b/PluralKit.Bot/Commands/Switch.cs index 9486ceba..fc910de0 100644 --- a/PluralKit.Bot/Commands/Switch.cs +++ b/PluralKit.Bot/Commands/Switch.cs @@ -92,18 +92,18 @@ namespace PluralKit.Bot // But, we do a prompt to confirm. var lastSwitchMembers = _repo.GetSwitchMembers(conn, lastTwoSwitches[0].Id); var lastSwitchMemberStr = string.Join(", ", await lastSwitchMembers.Select(m => m.NameFor(ctx)).ToListAsync()); - var lastSwitchTimeStr = lastTwoSwitches[0].Timestamp.FormatZoned(ctx.System); + var lastSwitchTime = lastTwoSwitches[0].Timestamp.ToUnixTimeSeconds(); // .FormatZoned(ctx.System) var lastSwitchDeltaStr = (SystemClock.Instance.GetCurrentInstant() - lastTwoSwitches[0].Timestamp).FormatDuration(); - var newSwitchTimeStr = time.FormatZoned(); + var newSwitchTime = time.ToInstant().ToUnixTimeSeconds(); var newSwitchDeltaStr = (SystemClock.Instance.GetCurrentInstant() - time.ToInstant()).FormatDuration(); // yeet - var msg = $"{Emojis.Warn} This will move the latest switch ({lastSwitchMemberStr}) from {lastSwitchTimeStr} ({lastSwitchDeltaStr} ago) to {newSwitchTimeStr} ({newSwitchDeltaStr} ago). Is this OK?"; - if (!await ctx.PromptYesNo(msg)) throw Errors.SwitchMoveCancelled; + var msg = $"{Emojis.Warn} This will move the latest switch ({lastSwitchMemberStr}) from ({lastSwitchDeltaStr} ago) to ({newSwitchDeltaStr} ago). Is this OK?"; + if (!await ctx.PromptYesNo(msg, "Move Switch")) throw Errors.SwitchMoveCancelled; // aaaand *now* we do the move await _repo.MoveSwitch(conn, lastTwoSwitches[0].Id, time.ToInstant()); - await ctx.Reply($"{Emojis.Success} Switch moved to {newSwitchTimeStr} ({newSwitchDeltaStr} ago)."); + await ctx.Reply($"{Emojis.Success} Switch moved to ({newSwitchDeltaStr} ago)."); } public async Task SwitchDelete(Context ctx) @@ -114,7 +114,7 @@ namespace PluralKit.Bot { // Subcommand: "delete all" var purgeMsg = $"{Emojis.Warn} This will delete *all registered switches* in your system. Are you sure you want to proceed?"; - if (!await ctx.PromptYesNo(purgeMsg)) + if (!await ctx.PromptYesNo(purgeMsg, "Clear Switches")) throw Errors.GenericCancelled(); await _db.Execute(c => _repo.DeleteAllSwitches(c, ctx.System.Id)); await ctx.Reply($"{Emojis.Success} Cleared system switches!"); @@ -144,7 +144,7 @@ namespace PluralKit.Bot msg = $"{Emojis.Warn} This will delete the latest switch ({lastSwitchMemberStr}, {lastSwitchDeltaStr} ago). The next latest switch is {secondSwitchMemberStr} ({secondSwitchDeltaStr} ago). Is this okay?"; } - if (!await ctx.PromptYesNo(msg)) throw Errors.SwitchDeleteCancelled; + if (!await ctx.PromptYesNo(msg, "Delete Switch")) throw Errors.SwitchDeleteCancelled; await _repo.DeleteSwitch(conn, lastTwoSwitches[0].Id); await ctx.Reply($"{Emojis.Success} Switch deleted."); diff --git a/PluralKit.Bot/Commands/SystemEdit.cs b/PluralKit.Bot/Commands/SystemEdit.cs index 1e1988ec..a439041a 100644 --- a/PluralKit.Bot/Commands/SystemEdit.cs +++ b/PluralKit.Bot/Commands/SystemEdit.cs @@ -294,7 +294,7 @@ namespace PluralKit.Bot var currentTime = SystemClock.Instance.GetCurrentInstant().InZone(zone); var msg = $"This will change the system time zone to **{zone.Id}**. The current time is **{currentTime.FormatZoned()}**. Is this correct?"; - if (!await ctx.PromptYesNo(msg)) throw Errors.TimezoneChangeCancelled; + if (!await ctx.PromptYesNo(msg, "Change Timezone")) throw Errors.TimezoneChangeCancelled; var patch = new SystemPatch {UiTz = zone.Id}; await _db.Execute(conn => _repo.UpdateSystem(conn, ctx.System.Id, patch)); diff --git a/PluralKit.Bot/Commands/SystemLink.cs b/PluralKit.Bot/Commands/SystemLink.cs index 0ebc0d83..cc8736ba 100644 --- a/PluralKit.Bot/Commands/SystemLink.cs +++ b/PluralKit.Bot/Commands/SystemLink.cs @@ -34,9 +34,8 @@ namespace PluralKit.Bot if (existingAccount != null) throw Errors.AccountInOtherSystem(existingAccount); - var msg = $"{account.Mention()}, please confirm the link by clicking the {Emojis.Success} reaction on this message."; - var mentions = new AllowedMentions {Users = new[] {account.Id}}; - if (!await ctx.PromptYesNo(msg, user: account, mentions: mentions, matchFlag: false)) throw Errors.MemberLinkCancelled; + var msg = $"{account.Mention()}, please confirm the link."; + if (!await ctx.PromptYesNo(msg, "Confirm", user: account, matchFlag: false)) throw Errors.MemberLinkCancelled; await _repo.AddAccount(conn, ctx.System.Id, account.Id); await ctx.Reply($"{Emojis.Success} Account linked to system."); } @@ -58,7 +57,7 @@ namespace PluralKit.Bot if (accountIds.Count == 1) throw Errors.UnlinkingLastAccount; var msg = $"Are you sure you want to unlink <@{id}> from your system?"; - if (!await ctx.PromptYesNo(msg)) throw Errors.MemberUnlinkCancelled; + if (!await ctx.PromptYesNo(msg, "Unlink")) throw Errors.MemberUnlinkCancelled; await _repo.RemoveAccount(conn, ctx.System.Id, id); await ctx.Reply($"{Emojis.Success} Account unlinked."); diff --git a/PluralKit.Bot/Interactive/BaseInteractive.cs b/PluralKit.Bot/Interactive/BaseInteractive.cs index 36eb9f57..e5917887 100644 --- a/PluralKit.Bot/Interactive/BaseInteractive.cs +++ b/PluralKit.Bot/Interactive/BaseInteractive.cs @@ -6,6 +6,7 @@ using System.Threading.Tasks; using Autofac; +using Myriad.Rest.Types; using Myriad.Rest.Types.Requests; using Myriad.Types; @@ -15,10 +16,11 @@ namespace PluralKit.Bot.Interactive { public abstract class BaseInteractive { - private readonly Context _ctx; - private readonly List