feat: implement system delete command

This commit is contained in:
dusk 2025-04-04 04:47:00 +09:00
parent 9e74835e4b
commit 047bdd870d
No known key found for this signature in database
4 changed files with 19 additions and 12 deletions

View file

@ -95,6 +95,7 @@ public partial class CommandTree
Commands.SystemShowBanner(var param, var flags) => ctx.Execute<SystemEdit>(SystemBannerImage, m => m.ShowBannerImage(ctx, param.target, flags.GetReplyFormat())),
Commands.SystemClearBanner(var param, var flags) => ctx.Execute<SystemEdit>(SystemBannerImage, m => m.ClearBannerImage(ctx, ctx.System, flags.yes)),
Commands.SystemChangeBanner(var param, _) => ctx.Execute<SystemEdit>(SystemBannerImage, m => m.ChangeBannerImage(ctx, ctx.System, param.banner)),
Commands.SystemDelete(_, var flags) => ctx.Execute<SystemEdit>(SystemDelete, m => m.Delete(ctx, ctx.System, flags.no_export)),
_ =>
// this should only ever occur when deving if commands are not implemented...
ctx.Reply(
@ -364,8 +365,6 @@ public partial class CommandTree
await ctx.CheckSystem(target).Execute<Groups>(GroupList, g => g.ListSystemGroups(ctx, target));
else if (ctx.Match("privacy"))
await ctx.CheckSystem(target).Execute<SystemEdit>(SystemPrivacy, m => m.SystemPrivacy(ctx, target));
else if (ctx.Match("delete", "remove", "destroy", "erase", "yeet"))
await ctx.CheckSystem(target).Execute<SystemEdit>(SystemDelete, m => m.Delete(ctx, target));
else if (ctx.Match("id"))
await ctx.CheckSystem(target).Execute<System>(SystemId, m => m.DisplayId(ctx, target));
else if (ctx.Match("random", "rand", "r"))

View file

@ -774,10 +774,9 @@ public class SystemEdit
: ctx.Reply(msg));
}
public async Task Delete(Context ctx, PKSystem target)
public async Task Delete(Context ctx, PKSystem target, bool noExport)
{
ctx.CheckSystem().CheckOwnSystem(target);
var noExport = ctx.MatchFlag("ne", "no-export");
var warnMsg = $"{Emojis.Warn} Are you sure you want to delete your system? If so, reply to this message with your system's ID (`{target.DisplayHid(ctx.Config)}`).\n";
if (!noExport)