implement system link / unlink cmds

This commit is contained in:
dusk 2025-09-28 15:03:28 +00:00
parent 6d6dcc389f
commit 228a177ea3
No known key found for this signature in database
3 changed files with 11 additions and 6 deletions

View file

@ -171,6 +171,8 @@ public partial class CommandTree
? ctx.Execute<Random>(GroupRandom, m => m.Group(ctx, param.target, flags.all, flags.show_embed))
: ctx.Execute<Random>(MemberRandom, m => m.Member(ctx, param.target, flags.all, flags.show_embed)),
Commands.GroupRandomMember(var param, var flags) => ctx.Execute<Random>(GroupMemberRandom, m => m.GroupMember(ctx, param.target, flags.all, flags.show_embed)),
Commands.SystemLink => ctx.Execute<SystemLink>(Link, m => m.LinkSystem(ctx)),
Commands.SystemUnlink(var param, _) => ctx.Execute<SystemLink>(Unlink, m => m.UnlinkAccount(ctx, param.target)),
_ =>
// this should only ever occur when deving if commands are not implemented...
ctx.Reply(
@ -194,10 +196,6 @@ public partial class CommandTree
return HandleServerConfigCommand(ctx);
if (ctx.Match("list", "find", "members", "search", "query", "l", "f", "fd", "ls"))
return ctx.Execute<SystemList>(SystemList, m => m.MemberList(ctx, ctx.System));
if (ctx.Match("link"))
return ctx.Execute<SystemLink>(Link, m => m.LinkSystem(ctx));
if (ctx.Match("unlink"))
return ctx.Execute<SystemLink>(Unlink, m => m.UnlinkAccount(ctx));
if (ctx.Match("token"))
if (ctx.Match("refresh", "renew", "invalidate", "reroll", "regen"))
return ctx.Execute<Api>(TokenRefresh, m => m.RefreshToken(ctx));

View file

@ -26,12 +26,12 @@ public class SystemLink
await ctx.Reply($"{Emojis.Success} Account linked to system.");
}
public async Task UnlinkAccount(Context ctx)
public async Task UnlinkAccount(Context ctx, string idRaw)
{
ctx.CheckSystem();
ulong id;
if (!ctx.MatchUserRaw(out id))
if (!idRaw.TryParseMention(out id))
throw new PKSyntaxError("You must pass an account to unlink from (either ID or @mention).");
var accountIds = (await ctx.Repository.GetSystemAccounts(ctx.System.Id)).ToList();

View file

@ -245,6 +245,12 @@ pub fn edit() -> impl Iterator<Item = Command> {
]
.into_iter();
let system_link = [
command!("link" => "system_link"),
command!("unlink", ("target", OpaqueString) => "system_unlink"),
]
.into_iter();
system_new_cmd
.chain(system_name_self_cmd)
.chain(system_server_name_self_cmd)
@ -271,4 +277,5 @@ pub fn edit() -> impl Iterator<Item = Command> {
.chain(system_banner_cmd)
.chain(system_info_cmd)
.chain(system_front_cmd)
.chain(system_link)
}