Merge pull request #368 from spiralw/feat/yes-no-buttons
Use buttons for all yes/no prompts
This commit is contained in:
@@ -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.");
|
||||
}
|
||||
|
||||
|
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -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();
|
||||
|
@@ -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
|
||||
|
@@ -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();
|
||||
}
|
||||
|
||||
|
@@ -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 <t:{lastSwitchTime}> ({lastSwitchDeltaStr} ago) to <t:{newSwitchTime}> ({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 <t:{newSwitchTime}> ({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.");
|
||||
|
@@ -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));
|
||||
|
@@ -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.");
|
||||
|
Reference in New Issue
Block a user