mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-13 17:20:14 +00:00
remove rest of the parsing in csharp bot
This commit is contained in:
parent
15ffd16c01
commit
479e0a59b5
35 changed files with 242 additions and 409 deletions
|
|
@ -111,7 +111,7 @@ public class Admin
|
|||
return eb.Build();
|
||||
}
|
||||
|
||||
public async Task UpdateSystemId(Context ctx, PKSystem target, string newHid)
|
||||
public async Task UpdateSystemId(Context ctx, PKSystem target, string newHid, bool confirmYes)
|
||||
{
|
||||
ctx.AssertBotAdmin();
|
||||
|
||||
|
|
@ -121,14 +121,14 @@ public class Admin
|
|||
|
||||
await ctx.Reply(null, await CreateEmbed(ctx, target));
|
||||
|
||||
if (!await ctx.PromptYesNo($"Change system ID of `{target.Hid}` to `{newHid}`?", "Change"))
|
||||
if (!await ctx.PromptYesNo($"Change system ID of `{target.Hid}` to `{newHid}`?", "Change", flagValue: confirmYes))
|
||||
throw new PKError("ID change cancelled.");
|
||||
|
||||
await ctx.Repository.UpdateSystem(target.Id, new SystemPatch { Hid = newHid });
|
||||
await ctx.Reply($"{Emojis.Success} System ID updated (`{target.Hid}` -> `{newHid}`).");
|
||||
}
|
||||
|
||||
public async Task UpdateMemberId(Context ctx, PKMember target, string newHid)
|
||||
public async Task UpdateMemberId(Context ctx, PKMember target, string newHid, bool confirmYes)
|
||||
{
|
||||
ctx.AssertBotAdmin();
|
||||
|
||||
|
|
@ -141,7 +141,7 @@ public class Admin
|
|||
|
||||
if (!await ctx.PromptYesNo(
|
||||
$"Change member ID of **{target.NameFor(LookupContext.ByNonOwner)}** (`{target.Hid}`) to `{newHid}`?",
|
||||
"Change"
|
||||
"Change", flagValue: confirmYes
|
||||
))
|
||||
throw new PKError("ID change cancelled.");
|
||||
|
||||
|
|
@ -149,7 +149,7 @@ public class Admin
|
|||
await ctx.Reply($"{Emojis.Success} Member ID updated (`{target.Hid}` -> `{newHid}`).");
|
||||
}
|
||||
|
||||
public async Task UpdateGroupId(Context ctx, PKGroup target, string newHid)
|
||||
public async Task UpdateGroupId(Context ctx, PKGroup target, string newHid, bool confirmYes)
|
||||
{
|
||||
ctx.AssertBotAdmin();
|
||||
|
||||
|
|
@ -161,7 +161,7 @@ public class Admin
|
|||
await ctx.Reply(null, await CreateEmbed(ctx, system));
|
||||
|
||||
if (!await ctx.PromptYesNo($"Change group ID of **{target.Name}** (`{target.Hid}`) to `{newHid}`?",
|
||||
"Change"
|
||||
"Change", flagValue: confirmYes
|
||||
))
|
||||
throw new PKError("ID change cancelled.");
|
||||
|
||||
|
|
@ -169,13 +169,13 @@ public class Admin
|
|||
await ctx.Reply($"{Emojis.Success} Group ID updated (`{target.Hid}` -> `{newHid}`).");
|
||||
}
|
||||
|
||||
public async Task RerollSystemId(Context ctx, PKSystem target)
|
||||
public async Task RerollSystemId(Context ctx, PKSystem target, bool confirmYes)
|
||||
{
|
||||
ctx.AssertBotAdmin();
|
||||
|
||||
await ctx.Reply(null, await CreateEmbed(ctx, target));
|
||||
|
||||
if (!await ctx.PromptYesNo($"Reroll system ID `{target.Hid}`?", "Reroll"))
|
||||
if (!await ctx.PromptYesNo($"Reroll system ID `{target.Hid}`?", "Reroll", flagValue: confirmYes))
|
||||
throw new PKError("ID change cancelled.");
|
||||
|
||||
var query = new Query("systems").AsUpdate(new
|
||||
|
|
@ -188,7 +188,7 @@ public class Admin
|
|||
await ctx.Reply($"{Emojis.Success} System ID updated (`{target.Hid}` -> `{newHid}`).");
|
||||
}
|
||||
|
||||
public async Task RerollMemberId(Context ctx, PKMember target)
|
||||
public async Task RerollMemberId(Context ctx, PKMember target, bool confirmYes)
|
||||
{
|
||||
ctx.AssertBotAdmin();
|
||||
|
||||
|
|
@ -197,7 +197,7 @@ public class Admin
|
|||
|
||||
if (!await ctx.PromptYesNo(
|
||||
$"Reroll member ID for **{target.NameFor(LookupContext.ByNonOwner)}** (`{target.Hid}`)?",
|
||||
"Reroll"
|
||||
"Reroll", flagValue: confirmYes
|
||||
))
|
||||
throw new PKError("ID change cancelled.");
|
||||
|
||||
|
|
@ -211,7 +211,7 @@ public class Admin
|
|||
await ctx.Reply($"{Emojis.Success} Member ID updated (`{target.Hid}` -> `{newHid}`).");
|
||||
}
|
||||
|
||||
public async Task RerollGroupId(Context ctx, PKGroup target)
|
||||
public async Task RerollGroupId(Context ctx, PKGroup target, bool confirmYes)
|
||||
{
|
||||
ctx.AssertBotAdmin();
|
||||
|
||||
|
|
@ -219,7 +219,7 @@ public class Admin
|
|||
await ctx.Reply(null, await CreateEmbed(ctx, system));
|
||||
|
||||
if (!await ctx.PromptYesNo($"Reroll group ID for **{target.Name}** (`{target.Hid}`)?",
|
||||
"Change"
|
||||
"Change", flagValue: confirmYes
|
||||
))
|
||||
throw new PKError("ID change cancelled.");
|
||||
|
||||
|
|
@ -233,7 +233,7 @@ public class Admin
|
|||
await ctx.Reply($"{Emojis.Success} Group ID updated (`{target.Hid}` -> `{newHid}`).");
|
||||
}
|
||||
|
||||
public async Task SystemMemberLimit(Context ctx, PKSystem target, int? newLimit)
|
||||
public async Task SystemMemberLimit(Context ctx, PKSystem target, int? newLimit, bool confirmYes)
|
||||
{
|
||||
ctx.AssertBotAdmin();
|
||||
|
||||
|
|
@ -247,14 +247,14 @@ public class Admin
|
|||
}
|
||||
|
||||
await ctx.Reply(null, await CreateEmbed(ctx, target));
|
||||
if (!await ctx.PromptYesNo($"Update member limit from **{currentLimit}** to **{newLimit}**?", "Update"))
|
||||
if (!await ctx.PromptYesNo($"Update member limit from **{currentLimit}** to **{newLimit}**?", "Update", flagValue: confirmYes))
|
||||
throw new PKError("Member limit change cancelled.");
|
||||
|
||||
await ctx.Repository.UpdateSystemConfig(target.Id, new SystemConfigPatch { MemberLimitOverride = newLimit });
|
||||
await ctx.Reply($"{Emojis.Success} Member limit updated.");
|
||||
}
|
||||
|
||||
public async Task SystemGroupLimit(Context ctx, PKSystem target, int? newLimit)
|
||||
public async Task SystemGroupLimit(Context ctx, PKSystem target, int? newLimit, bool confirmYes)
|
||||
{
|
||||
ctx.AssertBotAdmin();
|
||||
|
||||
|
|
@ -268,14 +268,14 @@ public class Admin
|
|||
}
|
||||
|
||||
await ctx.Reply(null, await CreateEmbed(ctx, target));
|
||||
if (!await ctx.PromptYesNo($"Update group limit from **{currentLimit}** to **{newLimit}**?", "Update"))
|
||||
if (!await ctx.PromptYesNo($"Update group limit from **{currentLimit}** to **{newLimit}**?", "Update", flagValue: confirmYes))
|
||||
throw new PKError("Group limit change cancelled.");
|
||||
|
||||
await ctx.Repository.UpdateSystemConfig(target.Id, new SystemConfigPatch { GroupLimitOverride = newLimit });
|
||||
await ctx.Reply($"{Emojis.Success} Group limit updated.");
|
||||
}
|
||||
|
||||
public async Task SystemRecover(Context ctx, string systemToken, User account, bool rerollToken)
|
||||
public async Task SystemRecover(Context ctx, string systemToken, User account, bool rerollToken, bool confirmYes)
|
||||
{
|
||||
ctx.AssertBotAdmin();
|
||||
|
||||
|
|
@ -294,7 +294,7 @@ public class Admin
|
|||
var system = await ctx.Repository.GetSystem(systemId.Value!);
|
||||
await ctx.Reply(null, await CreateEmbed(ctx, system));
|
||||
|
||||
if (!await ctx.PromptYesNo($"Associate account {account.NameAndMention()} with system `{system.Hid}`?", "Recover account"))
|
||||
if (!await ctx.PromptYesNo($"Associate account {account.NameAndMention()} with system `{system.Hid}`?", "Recover account", flagValue: confirmYes))
|
||||
throw new PKError("System recovery cancelled.");
|
||||
|
||||
await ctx.Repository.AddAccount(system.Id, account.Id);
|
||||
|
|
@ -402,7 +402,7 @@ public class Admin
|
|||
}
|
||||
}
|
||||
|
||||
public async Task AbuseLogDescription(Context ctx, User? account, string? id, string? description, bool clear)
|
||||
public async Task AbuseLogDescription(Context ctx, User? account, string? id, string? description, bool clear, bool confirmClear)
|
||||
{
|
||||
ctx.AssertBotAdmin();
|
||||
|
||||
|
|
@ -410,7 +410,7 @@ public class Admin
|
|||
if (abuseLog == null)
|
||||
return;
|
||||
|
||||
if (clear && await ctx.ConfirmClear("this abuse log description"))
|
||||
if (clear && await ctx.ConfirmClear("this abuse log description", confirmClear))
|
||||
{
|
||||
await ctx.Repository.UpdateAbuseLog(abuseLog.Id, new AbuseLogPatch { Description = null });
|
||||
await ctx.Reply($"{Emojis.Success} Abuse log description cleared.");
|
||||
|
|
|
|||
|
|
@ -115,28 +115,32 @@ public class Api
|
|||
}
|
||||
}
|
||||
|
||||
public async Task SystemWebhook(Context ctx)
|
||||
public async Task GetSystemWebhook(Context ctx)
|
||||
{
|
||||
ctx.CheckSystem().CheckDMContext();
|
||||
|
||||
if (!ctx.HasNext(false))
|
||||
{
|
||||
if (ctx.System.WebhookUrl == null)
|
||||
await ctx.Reply($"Your system does not have a webhook URL set. Set one with `{ctx.DefaultPrefix}system webhook <url>`!");
|
||||
else
|
||||
await ctx.Reply($"Your system's webhook URL is <{ctx.System.WebhookUrl}>.");
|
||||
if (ctx.System.WebhookUrl == null)
|
||||
await ctx.Reply($"Your system does not have a webhook URL set. Set one with `{ctx.DefaultPrefix}system webhook <url>`!");
|
||||
else
|
||||
await ctx.Reply($"Your system's webhook URL is <{ctx.System.WebhookUrl}>.");
|
||||
}
|
||||
|
||||
public async Task ClearSystemWebhook(Context ctx, bool confirmYes)
|
||||
{
|
||||
ctx.CheckSystem().CheckDMContext();
|
||||
|
||||
if (!await ctx.ConfirmClear("your system's webhook URL", confirmYes))
|
||||
return;
|
||||
}
|
||||
|
||||
if (ctx.MatchClear() && await ctx.ConfirmClear("your system's webhook URL"))
|
||||
{
|
||||
await ctx.Repository.UpdateSystem(ctx.System.Id, new SystemPatch { WebhookUrl = null, WebhookToken = null });
|
||||
await ctx.Repository.UpdateSystem(ctx.System.Id, new SystemPatch { WebhookUrl = null, WebhookToken = null });
|
||||
|
||||
await ctx.Reply($"{Emojis.Success} System webhook URL removed.");
|
||||
return;
|
||||
}
|
||||
await ctx.Reply($"{Emojis.Success} System webhook URL removed.");
|
||||
}
|
||||
|
||||
public async Task SetSystemWebhook(Context ctx, string newUrl)
|
||||
{
|
||||
ctx.CheckSystem().CheckDMContext();
|
||||
|
||||
var newUrl = ctx.RemainderOrNull();
|
||||
if (!await DispatchExt.ValidateUri(newUrl))
|
||||
throw new PKError($"The URL {newUrl.AsCode()} is invalid or I cannot access it. Are you sure this is a valid, publicly accessible URL?");
|
||||
|
||||
|
|
|
|||
|
|
@ -290,7 +290,7 @@ public class Config
|
|||
await ctx.Reply($"{Emojis.Success} System time zone cleared (set to UTC).");
|
||||
}
|
||||
|
||||
public async Task EditSystemTimezone(Context ctx, string zoneStr)
|
||||
public async Task EditSystemTimezone(Context ctx, string zoneStr, bool confirmYes = false)
|
||||
{
|
||||
if (ctx.System == null) throw Errors.NoSystemError(ctx.DefaultPrefix);
|
||||
|
||||
|
|
@ -299,7 +299,7 @@ public class Config
|
|||
|
||||
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, "Change Timezone")) throw Errors.TimezoneChangeCancelled;
|
||||
if (!await ctx.PromptYesNo(msg, "Change Timezone", flagValue: confirmYes)) throw Errors.TimezoneChangeCancelled;
|
||||
|
||||
await ctx.Repository.UpdateSystemConfig(ctx.System.Id, new() { UiTz = zone.Id });
|
||||
|
||||
|
|
|
|||
|
|
@ -37,20 +37,16 @@ public class Fun
|
|||
public Task Meow(Context ctx) =>
|
||||
ctx.Reply("*mrrp :3*");
|
||||
|
||||
public Task Error(Context ctx)
|
||||
{
|
||||
if (ctx.Match("message"))
|
||||
return ctx.Reply("> **Error code:** `50f3c7b439d111ecab2023a5431fffbd`", new EmbedBuilder()
|
||||
.Color(0xE74C3C)
|
||||
.Title("Internal error occurred")
|
||||
.Description(
|
||||
"For support, please send the error code above in **#bug-reports-and-errors** on **[the support server *(click to join)*](https://discord.gg/PczBt78)** with a description of what you were doing at the time.")
|
||||
.Footer(new Embed.EmbedFooter("50f3c7b439d111ecab2023a5431fffbd"))
|
||||
.Timestamp(SystemClock.Instance.GetCurrentInstant().ToDateTimeOffset().ToString("O"))
|
||||
.Build()
|
||||
);
|
||||
public Task ErrorMessage(Context ctx) => ctx.Reply("> **Error code:** `50f3c7b439d111ecab2023a5431fffbd`", new EmbedBuilder()
|
||||
.Color(0xE74C3C)
|
||||
.Title("Internal error occurred")
|
||||
.Description(
|
||||
"For support, please send the error code above in **#bug-reports-and-errors** on **[the support server *(click to join)*](https://discord.gg/PczBt78)** with a description of what you were doing at the time.")
|
||||
.Footer(new Embed.EmbedFooter("50f3c7b439d111ecab2023a5431fffbd"))
|
||||
.Timestamp(SystemClock.Instance.GetCurrentInstant().ToDateTimeOffset().ToString("O"))
|
||||
.Build()
|
||||
);
|
||||
|
||||
return ctx.Reply(
|
||||
$"{Emojis.Error} Unknown command {"error".AsCode()}. For a list of possible commands, see <https://pluralkit.me/commands>.");
|
||||
}
|
||||
public Task Error(Context ctx) => ctx.Reply(
|
||||
$"{Emojis.Error} Unknown command {"error".AsCode()}. For a list of possible commands, see <https://pluralkit.me/commands>.");
|
||||
}
|
||||
|
|
@ -51,7 +51,7 @@ public class GroupMember
|
|||
groups.Count - toAction.Count));
|
||||
}
|
||||
|
||||
public async Task ListMemberGroups(Context ctx, PKMember target, string? query, IHasListOptions flags)
|
||||
public async Task ListMemberGroups(Context ctx, PKMember target, string? query, IHasListOptions flags, bool all)
|
||||
{
|
||||
var targetSystem = await ctx.Repository.GetSystem(target.System);
|
||||
var opts = flags.GetListOptions(ctx, target.System);
|
||||
|
|
@ -80,10 +80,10 @@ public class GroupMember
|
|||
title.Append($" matching **{opts.Search.Truncate(100)}**");
|
||||
|
||||
await ctx.RenderGroupList(ctx.LookupContextFor(target.System), target.System, title.ToString(),
|
||||
target.Color, opts);
|
||||
target.Color, opts, all);
|
||||
}
|
||||
|
||||
public async Task AddRemoveMembers(Context ctx, PKGroup target, List<PKMember> _members, Groups.AddRemoveOperation op, bool all)
|
||||
public async Task AddRemoveMembers(Context ctx, PKGroup target, List<PKMember> _members, Groups.AddRemoveOperation op, bool all, bool confirmYes)
|
||||
{
|
||||
ctx.CheckOwnGroup(target);
|
||||
|
||||
|
|
@ -126,7 +126,7 @@ public class GroupMember
|
|||
.Where(m => existingMembersInGroup.Contains(m.Value))
|
||||
.ToList();
|
||||
|
||||
if (all && !await ctx.PromptYesNo($"Are you sure you want to remove all members from group {target.Reference(ctx)}?", "Empty Group")) throw Errors.GenericCancelled();
|
||||
if (all && !await ctx.PromptYesNo($"Are you sure you want to remove all members from group {target.Reference(ctx)}?", "Empty Group", flagValue: confirmYes)) throw Errors.GenericCancelled();
|
||||
|
||||
await ctx.Repository.RemoveMembersFromGroup(target.Id, toAction);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ public class Groups
|
|||
_avatarHosting = avatarHosting;
|
||||
}
|
||||
|
||||
public async Task CreateGroup(Context ctx, string groupName)
|
||||
public async Task CreateGroup(Context ctx, string groupName, bool confirmYes = false)
|
||||
{
|
||||
ctx.CheckSystem();
|
||||
|
||||
|
|
@ -53,7 +53,7 @@ public class Groups
|
|||
{
|
||||
var msg =
|
||||
$"{Emojis.Warn} You already have a group in your system with the name \"{existingGroup.Name}\" (with ID `{existingGroup.DisplayHid(ctx.Config)}`). Do you want to create another group with the same name?";
|
||||
if (!await ctx.PromptYesNo(msg, "Create"))
|
||||
if (!await ctx.PromptYesNo(msg, "Create", flagValue: confirmYes))
|
||||
throw new PKError("Group creation cancelled.");
|
||||
}
|
||||
|
||||
|
|
@ -98,7 +98,7 @@ public class Groups
|
|||
await ctx.Reply(replyStr, eb.Build());
|
||||
}
|
||||
|
||||
public async Task RenameGroup(Context ctx, PKGroup target, string newName)
|
||||
public async Task RenameGroup(Context ctx, PKGroup target, string? newName, bool confirmYes = false)
|
||||
{
|
||||
ctx.CheckOwnGroup(target);
|
||||
|
||||
|
|
@ -113,7 +113,7 @@ public class Groups
|
|||
{
|
||||
var msg =
|
||||
$"{Emojis.Warn} You already have a group in your system with the name \"{existingGroup.Name}\" (with ID `{existingGroup.DisplayHid(ctx.Config)}`). Do you want to rename this group to that name too?";
|
||||
if (!await ctx.PromptYesNo(msg, "Rename"))
|
||||
if (!await ctx.PromptYesNo(msg, "Rename", flagValue: confirmYes))
|
||||
throw new PKError("Group rename cancelled.");
|
||||
}
|
||||
|
||||
|
|
@ -320,10 +320,10 @@ public class Groups
|
|||
await ctx.Reply(embed: ebS.Build());
|
||||
}
|
||||
|
||||
public async Task ClearGroupIcon(Context ctx, PKGroup target)
|
||||
public async Task ClearGroupIcon(Context ctx, PKGroup target, bool confirmYes)
|
||||
{
|
||||
ctx.CheckOwnGroup(target);
|
||||
await ctx.ConfirmClear("this group's icon");
|
||||
await ctx.ConfirmClear("this group's icon", confirmYes);
|
||||
|
||||
await ctx.Repository.UpdateGroup(target.Id, new GroupPatch { Icon = null });
|
||||
await ctx.Reply($"{Emojis.Success} Group icon cleared.");
|
||||
|
|
@ -400,10 +400,10 @@ public class Groups
|
|||
await ctx.Reply(embed: ebS.Build());
|
||||
}
|
||||
|
||||
public async Task ClearGroupBanner(Context ctx, PKGroup target)
|
||||
public async Task ClearGroupBanner(Context ctx, PKGroup target, bool confirmYes)
|
||||
{
|
||||
ctx.CheckOwnGroup(target);
|
||||
await ctx.ConfirmClear("this group's banner image");
|
||||
await ctx.ConfirmClear("this group's banner image", confirmYes);
|
||||
|
||||
await ctx.Repository.UpdateGroup(target.Id, new GroupPatch { BannerImage = null });
|
||||
await ctx.Reply($"{Emojis.Success} Group banner image cleared.");
|
||||
|
|
@ -506,7 +506,7 @@ public class Groups
|
|||
files: [MiscUtils.GenerateColorPreview(color)]);
|
||||
}
|
||||
|
||||
public async Task ListSystemGroups(Context ctx, PKSystem system, string? query, IHasListOptions flags)
|
||||
public async Task ListSystemGroups(Context ctx, PKSystem system, string? query, IHasListOptions flags, bool all)
|
||||
{
|
||||
if (system == null)
|
||||
{
|
||||
|
|
@ -528,7 +528,8 @@ public class Groups
|
|||
system.Id,
|
||||
GetEmbedTitle(ctx, system, opts),
|
||||
system.Color,
|
||||
opts
|
||||
opts,
|
||||
all
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -547,16 +548,16 @@ public class Groups
|
|||
return title.ToString();
|
||||
}
|
||||
|
||||
public async Task ShowGroupCard(Context ctx, PKGroup target, bool showEmbed = false)
|
||||
public async Task ShowGroupCard(Context ctx, PKGroup target, bool showEmbed, bool all)
|
||||
{
|
||||
var system = await GetGroupSystem(ctx, target);
|
||||
if (showEmbed)
|
||||
{
|
||||
await ctx.Reply(text: EmbedService.LEGACY_EMBED_WARNING, embed: await _embeds.CreateGroupEmbed(ctx, system, target));
|
||||
await ctx.Reply(text: EmbedService.LEGACY_EMBED_WARNING, embed: await _embeds.CreateGroupEmbed(ctx, system, target, all));
|
||||
return;
|
||||
}
|
||||
|
||||
await ctx.Reply(components: await _embeds.CreateGroupMessageComponents(ctx, system, target));
|
||||
await ctx.Reply(components: await _embeds.CreateGroupMessageComponents(ctx, system, target, all));
|
||||
}
|
||||
|
||||
public async Task ShowGroupPrivacy(Context ctx, PKGroup target)
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ public class ImportExport
|
|||
_dmCache = dmCache;
|
||||
}
|
||||
|
||||
public async Task Import(Context ctx, string? inputUrl)
|
||||
public async Task Import(Context ctx, string? inputUrl, bool confirmYes)
|
||||
{
|
||||
inputUrl = inputUrl ?? ctx.Message.Attachments.FirstOrDefault()?.Url;
|
||||
if (inputUrl == null) throw Errors.NoImportFilePassed;
|
||||
|
|
@ -77,7 +77,7 @@ public class ImportExport
|
|||
async Task ConfirmImport(string message)
|
||||
{
|
||||
var msg = $"{message}\n\nDo you want to proceed with the import?";
|
||||
if (!await ctx.PromptYesNo(msg, "Proceed"))
|
||||
if (!await ctx.PromptYesNo(msg, "Proceed", flagValue: confirmYes))
|
||||
throw Errors.ImportCancelled;
|
||||
}
|
||||
|
||||
|
|
@ -86,7 +86,7 @@ public class ImportExport
|
|||
&& data.Value<JArray>("accounts").Contains(ctx.Author.Id.ToString()))
|
||||
{
|
||||
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, "Import")) throw Errors.ImportCancelled;
|
||||
if (!await ctx.PromptYesNo(msg, "Import", flagValue: confirmYes)) throw Errors.ImportCancelled;
|
||||
}
|
||||
|
||||
var result = await _dataFiles.ImportSystem(ctx.Author.Id, ctx.System, data, ConfirmImport);
|
||||
|
|
|
|||
|
|
@ -130,7 +130,7 @@ public static class ContextListExt
|
|||
}
|
||||
|
||||
public static async Task RenderGroupList(this Context ctx, LookupContext lookupCtx,
|
||||
SystemId system, string embedTitle, string color, ListOptions opts)
|
||||
SystemId system, string embedTitle, string color, ListOptions opts, bool all)
|
||||
{
|
||||
// We take an IDatabase instead of a IPKConnection so we don't keep the handle open for the entire runtime
|
||||
// We wanna release it as soon as the member list is actually *fetched*, instead of potentially minutes later (paginate timeout)
|
||||
|
|
@ -204,7 +204,7 @@ public static class ContextListExt
|
|||
{
|
||||
if (g.ListPrivacy == PrivacyLevel.Public || lookupCtx == LookupContext.ByOwner)
|
||||
{
|
||||
if (ctx.MatchFlag("all", "a"))
|
||||
if (all)
|
||||
{
|
||||
ret += $"({"member".ToQuantity(g.TotalMemberCount)})";
|
||||
}
|
||||
|
|
@ -242,7 +242,7 @@ public static class ContextListExt
|
|||
|
||||
if (g.ListPrivacy == PrivacyLevel.Public || lookupCtx == LookupContext.ByOwner)
|
||||
{
|
||||
if (ctx.MatchFlag("all", "a") && ctx.DirectLookupContextFor(system) == LookupContext.ByOwner)
|
||||
if (all && ctx.DirectLookupContextFor(system) == LookupContext.ByOwner)
|
||||
profile.Append($"\n**Member Count:** {g.TotalMemberCount}");
|
||||
else
|
||||
profile.Append($"\n**Member Count:** {g.PublicMemberCount}");
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ public class Member
|
|||
_avatarHosting = avatarHosting;
|
||||
}
|
||||
|
||||
public async Task NewMember(Context ctx, string? memberName)
|
||||
public async Task NewMember(Context ctx, string? memberName, bool confirmYes = false)
|
||||
{
|
||||
if (ctx.System == null) throw Errors.NoSystemError(ctx.DefaultPrefix);
|
||||
memberName = memberName ?? throw new PKSyntaxError("You must pass a member name.");
|
||||
|
|
@ -42,7 +42,7 @@ public class Member
|
|||
if (existingMember != null)
|
||||
{
|
||||
var msg = $"{Emojis.Warn} You already have a member in your system with the name \"{existingMember.NameFor(ctx)}\" (with ID `{existingMember.DisplayHid(ctx.Config)}`). Do you want to create another member with the same name?";
|
||||
if (!await ctx.PromptYesNo(msg, "Create")) throw new PKError("Member creation cancelled.");
|
||||
if (!await ctx.PromptYesNo(msg, "Create", flagValue: confirmYes)) throw new PKError("Member creation cancelled.");
|
||||
}
|
||||
|
||||
await using var conn = await ctx.Database.Obtain();
|
||||
|
|
|
|||
|
|
@ -17,10 +17,10 @@ public class MemberAvatar
|
|||
_avatarHosting = avatarHosting;
|
||||
}
|
||||
|
||||
private async Task AvatarClear(MemberAvatarLocation location, Context ctx, PKMember target, MemberGuildSettings? mgs)
|
||||
private async Task AvatarClear(MemberAvatarLocation location, Context ctx, PKMember target, MemberGuildSettings? mgs, bool confirmYes)
|
||||
{
|
||||
ctx.CheckSystem().CheckOwnMember(target);
|
||||
await ctx.ConfirmClear("this member's " + location.Name());
|
||||
await ctx.ConfirmClear("this member's " + location.Name(), confirmYes);
|
||||
|
||||
await UpdateAvatar(location, ctx, target, null);
|
||||
if (location == MemberAvatarLocation.Server)
|
||||
|
|
@ -149,10 +149,10 @@ public class MemberAvatar
|
|||
await AvatarShow(MemberAvatarLocation.Server, ctx, target, guildData, format);
|
||||
}
|
||||
|
||||
public async Task ClearServerAvatar(Context ctx, PKMember target)
|
||||
public async Task ClearServerAvatar(Context ctx, PKMember target, bool confirmYes)
|
||||
{
|
||||
var guildData = await GetServerAvatarGuildData(ctx, target);
|
||||
await AvatarClear(MemberAvatarLocation.Server, ctx, target, guildData);
|
||||
await AvatarClear(MemberAvatarLocation.Server, ctx, target, guildData, confirmYes);
|
||||
}
|
||||
|
||||
public async Task ChangeServerAvatar(Context ctx, PKMember target, ParsedImage avatar)
|
||||
|
|
@ -167,10 +167,10 @@ public class MemberAvatar
|
|||
await AvatarShow(MemberAvatarLocation.Member, ctx, target, guildData, format);
|
||||
}
|
||||
|
||||
public async Task ClearAvatar(Context ctx, PKMember target)
|
||||
public async Task ClearAvatar(Context ctx, PKMember target, bool confirmYes)
|
||||
{
|
||||
var guildData = await GetAvatarGuildData(ctx, target);
|
||||
await AvatarClear(MemberAvatarLocation.Member, ctx, target, guildData);
|
||||
await AvatarClear(MemberAvatarLocation.Member, ctx, target, guildData, confirmYes);
|
||||
}
|
||||
|
||||
public async Task ChangeAvatar(Context ctx, PKMember target, ParsedImage avatar)
|
||||
|
|
@ -185,10 +185,10 @@ public class MemberAvatar
|
|||
await AvatarShow(MemberAvatarLocation.MemberWebhook, ctx, target, guildData, format);
|
||||
}
|
||||
|
||||
public async Task ClearWebhookAvatar(Context ctx, PKMember target)
|
||||
public async Task ClearWebhookAvatar(Context ctx, PKMember target, bool confirmYes)
|
||||
{
|
||||
var guildData = await GetWebhookAvatarGuildData(ctx, target);
|
||||
await AvatarClear(MemberAvatarLocation.MemberWebhook, ctx, target, guildData);
|
||||
await AvatarClear(MemberAvatarLocation.MemberWebhook, ctx, target, guildData, confirmYes);
|
||||
}
|
||||
|
||||
public async Task ChangeWebhookAvatar(Context ctx, PKMember target, ParsedImage avatar)
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ public class MemberEdit
|
|||
}
|
||||
}
|
||||
|
||||
public async Task ChangeName(Context ctx, PKMember target, string newName)
|
||||
public async Task ChangeName(Context ctx, PKMember target, string newName, bool confirmYes)
|
||||
{
|
||||
ctx.CheckSystem().CheckOwnMember(target);
|
||||
|
||||
|
|
@ -58,7 +58,7 @@ public class MemberEdit
|
|||
{
|
||||
var msg =
|
||||
$"{Emojis.Warn} You already have a member in your system with the name \"{existingMember.NameFor(ctx)}\" (`{existingMember.DisplayHid(ctx.Config)}`). Do you want to rename this member to that name too?";
|
||||
if (!await ctx.PromptYesNo(msg, "Rename")) throw new PKError("Member renaming cancelled.");
|
||||
if (!await ctx.PromptYesNo(msg, "Rename", flagValue: confirmYes)) throw new PKError("Member renaming cancelled.");
|
||||
}
|
||||
|
||||
// Rename the member
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ public class MemberProxy
|
|||
await ctx.Reply($"This member's proxy tags are:\n{target.ProxyTagsString("\n")}");
|
||||
}
|
||||
|
||||
public async Task ClearProxy(Context ctx, PKMember target)
|
||||
public async Task ClearProxy(Context ctx, PKMember target, bool confirmYes = false)
|
||||
{
|
||||
ctx.CheckSystem().CheckOwnMember(target);
|
||||
|
||||
|
|
@ -22,7 +22,7 @@ public class MemberProxy
|
|||
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, "Clear"))
|
||||
if (!await ctx.PromptYesNo(msg, "Clear", flagValue: confirmYes))
|
||||
throw Errors.GenericCancelled();
|
||||
}
|
||||
|
||||
|
|
@ -32,7 +32,7 @@ public class MemberProxy
|
|||
await ctx.Reply($"{Emojis.Success} Proxy tags cleared.");
|
||||
}
|
||||
|
||||
public async Task AddProxy(Context ctx, PKMember target, string proxyString)
|
||||
public async Task AddProxy(Context ctx, PKMember target, string proxyString, bool confirmYes = false)
|
||||
{
|
||||
ctx.CheckSystem().CheckOwnMember(target);
|
||||
|
||||
|
|
@ -44,7 +44,7 @@ public class MemberProxy
|
|||
throw new PKError(
|
||||
$"Proxy tag too long ({tagToAdd.ProxyString.Length} > {Limits.MaxProxyTagLength} characters).");
|
||||
|
||||
if (!await WarnOnConflict(ctx, target, tagToAdd))
|
||||
if (!await WarnOnConflict(ctx, target, tagToAdd, confirmYes))
|
||||
throw Errors.GenericCancelled();
|
||||
|
||||
var newTags = target.ProxyTags.ToList();
|
||||
|
|
@ -72,7 +72,7 @@ public class MemberProxy
|
|||
await ctx.Reply($"{Emojis.Success} Removed proxy tags {tagToRemove.ProxyString.AsCode()}.");
|
||||
}
|
||||
|
||||
public async Task SetProxy(Context ctx, PKMember target, string proxyString)
|
||||
public async Task SetProxy(Context ctx, PKMember target, string proxyString, bool confirmYes = false)
|
||||
{
|
||||
ctx.CheckSystem().CheckOwnMember(target);
|
||||
|
||||
|
|
@ -82,7 +82,7 @@ public class MemberProxy
|
|||
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, "Replace"))
|
||||
if (!await ctx.PromptYesNo(msg, "Replace", flagValue: confirmYes))
|
||||
throw Errors.GenericCancelled();
|
||||
}
|
||||
|
||||
|
|
@ -90,7 +90,7 @@ public class MemberProxy
|
|||
throw new PKError(
|
||||
$"Proxy tag too long ({requestedTag.ProxyString.Length} > {Limits.MaxProxyTagLength} characters).");
|
||||
|
||||
if (!await WarnOnConflict(ctx, target, requestedTag))
|
||||
if (!await WarnOnConflict(ctx, target, requestedTag, confirmYes))
|
||||
throw Errors.GenericCancelled();
|
||||
|
||||
var newTags = new[] { requestedTag };
|
||||
|
|
@ -110,7 +110,7 @@ public class MemberProxy
|
|||
return new ProxyTag(prefixAndSuffix[0], prefixAndSuffix[1]);
|
||||
}
|
||||
|
||||
private async Task<bool> WarnOnConflict(Context ctx, PKMember target, ProxyTag newTag)
|
||||
private async Task<bool> WarnOnConflict(Context ctx, PKMember target, ProxyTag newTag, bool confirmYes = false)
|
||||
{
|
||||
var query = "select * from (select *, (unnest(proxy_tags)).prefix as prefix, (unnest(proxy_tags)).suffix as suffix from members where system = @System) as _ where prefix is not distinct from @Prefix and suffix is not distinct from @Suffix and id != @Existing";
|
||||
var conflicts = (await ctx.Database.Execute(conn => conn.QueryAsync<PKMember>(query,
|
||||
|
|
@ -120,6 +120,6 @@ public class MemberProxy
|
|||
|
||||
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, "Proceed");
|
||||
return await ctx.PromptYesNo(msg, "Proceed", flagValue: confirmYes);
|
||||
}
|
||||
}
|
||||
|
|
@ -322,9 +322,7 @@ public class ProxiedMessage
|
|||
{
|
||||
if (messageId == null)
|
||||
{
|
||||
if (!ctx.HasNext())
|
||||
throw new PKSyntaxError("You must pass a message ID or link.");
|
||||
throw new PKSyntaxError($"Could not parse {ctx.PeekArgument().AsCode()} as a message ID or link.");
|
||||
throw new PKSyntaxError("You must pass a message ID or link.");
|
||||
}
|
||||
|
||||
var message = await ctx.Repository.GetFullMessage(messageId.Value);
|
||||
|
|
|
|||
|
|
@ -74,12 +74,12 @@ public class Random
|
|||
{
|
||||
await ctx.Reply(
|
||||
text: EmbedService.LEGACY_EMBED_WARNING,
|
||||
embed: await _embeds.CreateGroupEmbed(ctx, target, groups.ToArray()[randInt]));
|
||||
embed: await _embeds.CreateGroupEmbed(ctx, target, groups.ToArray()[randInt], all));
|
||||
return;
|
||||
}
|
||||
|
||||
await ctx.Reply(
|
||||
components: await _embeds.CreateGroupMessageComponents(ctx, target, groups.ToArray()[randInt]));
|
||||
components: await _embeds.CreateGroupMessageComponents(ctx, target, groups.ToArray()[randInt], all));
|
||||
}
|
||||
|
||||
public async Task GroupMember(Context ctx, PKGroup group, GroupRandomMemberFlags flags)
|
||||
|
|
|
|||
|
|
@ -144,11 +144,11 @@ public class ServerConfig
|
|||
await ctx.Reply($"{Emojis.Success} Proxy logging channel set to <#{channel.Id}>.");
|
||||
}
|
||||
|
||||
public async Task ClearLogChannel(Context ctx)
|
||||
public async Task ClearLogChannel(Context ctx, bool confirmYes)
|
||||
{
|
||||
await ctx.CheckGuildContext().CheckAuthorPermission(PermissionSet.ManageGuild, "Manage Server");
|
||||
|
||||
if (!await ctx.ConfirmClear("the server log channel"))
|
||||
if (!await ctx.ConfirmClear("the server log channel", confirmYes))
|
||||
return;
|
||||
|
||||
await ctx.Repository.UpdateGuild(ctx.Guild.Id, new GuildPatch { LogChannel = null });
|
||||
|
|
|
|||
|
|
@ -57,14 +57,14 @@ public class Switch
|
|||
$"{Emojis.Success} Switch registered. Current fronters are now {string.Join(", ", members.Select(m => m.NameFor(ctx)))}.");
|
||||
}
|
||||
|
||||
public async Task SwitchMove(Context ctx, string timeToMove)
|
||||
public async Task SwitchMove(Context ctx, string str, bool confirmYes = false)
|
||||
{
|
||||
ctx.CheckSystem();
|
||||
|
||||
var tz = TzdbDateTimeZoneSource.Default.ForId(ctx.Config?.UiTz ?? "UTC");
|
||||
|
||||
var result = DateUtils.ParseDateTime(timeToMove, true, tz);
|
||||
if (result == null) throw Errors.InvalidDateTime(timeToMove);
|
||||
var result = DateUtils.ParseDateTime(str, true, tz);
|
||||
if (result == null) throw Errors.InvalidDateTime(str);
|
||||
|
||||
|
||||
var time = result.Value;
|
||||
|
|
@ -95,14 +95,14 @@ public class Switch
|
|||
// yeet
|
||||
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;
|
||||
if (!await ctx.PromptYesNo(msg, "Move Switch", flagValue: confirmYes)) throw Errors.SwitchMoveCancelled;
|
||||
|
||||
// aaaand *now* we do the move
|
||||
await ctx.Repository.MoveSwitch(lastTwoSwitches[0].Id, time.ToInstant());
|
||||
await ctx.Reply($"{Emojis.Success} Switch moved to <t:{newSwitchTime}> ({newSwitchDeltaStr} ago).");
|
||||
}
|
||||
|
||||
public async Task SwitchEdit(Context ctx, List<PKMember>? newMembers, bool newSwitch = false, bool first = false, bool remove = false, bool append = false, bool prepend = false)
|
||||
public async Task SwitchEdit(Context ctx, List<PKMember>? newMembers, bool newSwitch = false, bool first = false, bool remove = false, bool append = false, bool prepend = false, bool confirmYes = false)
|
||||
{
|
||||
ctx.CheckSystem();
|
||||
|
||||
|
|
@ -131,7 +131,7 @@ public class Switch
|
|||
await DoSwitchCommand(ctx, newMembers);
|
||||
}
|
||||
else
|
||||
await DoEditCommand(ctx, newMembers);
|
||||
await DoEditCommand(ctx, newMembers, confirmYes);
|
||||
}
|
||||
|
||||
public List<PKMember> PrependToSwitch(List<PKMember> members, List<PKMember> currentSwitchMembers)
|
||||
|
|
@ -167,13 +167,13 @@ public class Switch
|
|||
return members;
|
||||
}
|
||||
|
||||
public async Task SwitchEditOut(Context ctx)
|
||||
public async Task SwitchEditOut(Context ctx, bool confirmYes)
|
||||
{
|
||||
ctx.CheckSystem();
|
||||
await DoEditCommand(ctx, []);
|
||||
await DoEditCommand(ctx, [], confirmYes);
|
||||
}
|
||||
|
||||
public async Task DoEditCommand(Context ctx, ICollection<PKMember>? members)
|
||||
public async Task DoEditCommand(Context ctx, ICollection<PKMember>? members, bool confirmYes)
|
||||
{
|
||||
if (members == null) members = new List<PKMember>();
|
||||
|
||||
|
|
@ -203,7 +203,7 @@ public class Switch
|
|||
msg = $"{Emojis.Warn} This will turn the latest switch ({lastSwitchMemberStr}, {lastSwitchDeltaStr} ago) into a switch-out. Is this okay?";
|
||||
else
|
||||
msg = $"{Emojis.Warn} This will change the latest switch ({lastSwitchMemberStr}, {lastSwitchDeltaStr} ago) to {newSwitchMemberStr}. Is this okay?";
|
||||
if (!await ctx.PromptYesNo(msg, "Edit")) throw Errors.SwitchEditCancelled;
|
||||
if (!await ctx.PromptYesNo(msg, "Edit", flagValue: confirmYes)) throw Errors.SwitchEditCancelled;
|
||||
|
||||
// Actually edit the switch
|
||||
await ctx.Repository.EditSwitch(conn, lastSwitch.Id, members.Select(m => m.Id).ToList());
|
||||
|
|
@ -217,7 +217,7 @@ public class Switch
|
|||
await ctx.Reply($"{Emojis.Success} Switch edited. Current fronters are now {newSwitchMemberStr}.");
|
||||
}
|
||||
|
||||
public async Task SwitchDelete(Context ctx, bool all)
|
||||
public async Task SwitchDelete(Context ctx, bool all = false, bool confirmYes = false)
|
||||
{
|
||||
ctx.CheckSystem();
|
||||
|
||||
|
|
@ -226,7 +226,7 @@ public class Switch
|
|||
// 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, "Clear Switches"))
|
||||
if (!await ctx.PromptYesNo(purgeMsg, "Clear Switches", flagValue: confirmYes))
|
||||
throw Errors.GenericCancelled();
|
||||
await ctx.Repository.DeleteAllSwitches(ctx.System.Id);
|
||||
await ctx.Reply($"{Emojis.Success} Cleared system switches!");
|
||||
|
|
@ -258,7 +258,7 @@ public class Switch
|
|||
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, "Delete Switch")) throw Errors.SwitchDeleteCancelled;
|
||||
if (!await ctx.PromptYesNo(msg, "Delete Switch", flagValue: confirmYes)) throw Errors.SwitchDeleteCancelled;
|
||||
await ctx.Repository.DeleteSwitch(lastTwoSwitches[0].Id);
|
||||
|
||||
await ctx.Reply($"{Emojis.Success} Switch deleted.");
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ public class SystemFront
|
|||
await ctx.Reply(embed: await _embeds.CreateFronterEmbed(sw, ctx.Zone, ctx.LookupContextFor(system.Id)));
|
||||
}
|
||||
|
||||
public async Task FrontHistory(Context ctx, PKSystem system, bool clear = false)
|
||||
public async Task FrontHistory(Context ctx, PKSystem system, bool showMemberId, bool clear = false)
|
||||
{
|
||||
if (clear)
|
||||
{
|
||||
|
|
@ -55,8 +55,6 @@ public class SystemFront
|
|||
embedTitle = $"Front history of {guildSettings.DisplayName} (`{system.Hid}`)";
|
||||
}
|
||||
|
||||
var showMemberId = ctx.MatchFlag("with-id", "wid");
|
||||
|
||||
await ctx.Paginate(
|
||||
sws,
|
||||
totalSwitches,
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ public class SystemLink
|
|||
await ctx.Reply($"{Emojis.Success} Account linked to system.");
|
||||
}
|
||||
|
||||
public async Task UnlinkAccount(Context ctx, string idRaw)
|
||||
public async Task UnlinkAccount(Context ctx, string idRaw, bool confirmYes)
|
||||
{
|
||||
ctx.CheckSystem();
|
||||
|
||||
|
|
@ -38,7 +38,7 @@ public class SystemLink
|
|||
if (accountIds.Count == 1) throw Errors.UnlinkingLastAccount(ctx.DefaultPrefix);
|
||||
|
||||
var msg = $"Are you sure you want to unlink <@{id}> from your system?";
|
||||
if (!await ctx.PromptYesNo(msg, "Unlink")) throw Errors.MemberUnlinkCancelled;
|
||||
if (!await ctx.PromptYesNo(msg, "Unlink", flagValue: confirmYes)) throw Errors.MemberUnlinkCancelled;
|
||||
|
||||
await ctx.Repository.RemoveAccount(ctx.System.Id, id);
|
||||
await ctx.Reply($"{Emojis.Success} Account unlinked.");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue