diff --git a/PluralKit.Bot/CommandMeta/CommandTree.cs b/PluralKit.Bot/CommandMeta/CommandTree.cs index b542a87a..f16e4360 100644 --- a/PluralKit.Bot/CommandMeta/CommandTree.cs +++ b/PluralKit.Bot/CommandMeta/CommandTree.cs @@ -171,6 +171,8 @@ public partial class CommandTree ? ctx.Execute(GroupRandom, m => m.Group(ctx, param.target, flags.all, flags.show_embed)) : ctx.Execute(MemberRandom, m => m.Member(ctx, param.target, flags.all, flags.show_embed)), Commands.GroupRandomMember(var param, var flags) => ctx.Execute(GroupMemberRandom, m => m.GroupMember(ctx, param.target, flags.all, flags.show_embed)), + Commands.SystemLink => ctx.Execute(Link, m => m.LinkSystem(ctx)), + Commands.SystemUnlink(var param, _) => ctx.Execute(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, m => m.MemberList(ctx, ctx.System)); - if (ctx.Match("link")) - return ctx.Execute(Link, m => m.LinkSystem(ctx)); - if (ctx.Match("unlink")) - return ctx.Execute(Unlink, m => m.UnlinkAccount(ctx)); if (ctx.Match("token")) if (ctx.Match("refresh", "renew", "invalidate", "reroll", "regen")) return ctx.Execute(TokenRefresh, m => m.RefreshToken(ctx)); diff --git a/PluralKit.Bot/Commands/SystemLink.cs b/PluralKit.Bot/Commands/SystemLink.cs index df0743fb..8b4b1881 100644 --- a/PluralKit.Bot/Commands/SystemLink.cs +++ b/PluralKit.Bot/Commands/SystemLink.cs @@ -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(); diff --git a/crates/command_definitions/src/system.rs b/crates/command_definitions/src/system.rs index e6fd5b66..7de89f84 100644 --- a/crates/command_definitions/src/system.rs +++ b/crates/command_definitions/src/system.rs @@ -245,6 +245,12 @@ pub fn edit() -> impl Iterator { ] .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 { .chain(system_banner_cmd) .chain(system_info_cmd) .chain(system_front_cmd) + .chain(system_link) }