diff --git a/PluralKit.Bot/CommandMeta/CommandTree.cs b/PluralKit.Bot/CommandMeta/CommandTree.cs index 3f9955ae..51448a3c 100644 --- a/PluralKit.Bot/CommandMeta/CommandTree.cs +++ b/PluralKit.Bot/CommandMeta/CommandTree.cs @@ -229,6 +229,8 @@ public partial class CommandTree Commands.GroupDelete(var param, var flags) => ctx.Execute(GroupDelete, g => g.DeleteGroup(ctx, param.target)), Commands.GroupId(var param, _) => ctx.Execute(GroupId, g => g.DisplayId(ctx, param.target)), Commands.GroupFronterPercent(var param, var flags) => ctx.Execute(GroupFrontPercent, g => g.FrontPercent(ctx, null, flags.duration, flags.fronters_only, flags.flat, param.target)), + Commands.TokenDisplay => ctx.Execute(TokenGet, m => m.GetToken(ctx)), + Commands.TokenRefresh => ctx.Execute(TokenRefresh, m => m.RefreshToken(ctx)), _ => // this should only ever occur when deving if commands are not implemented... ctx.Reply( @@ -242,11 +244,6 @@ public partial class CommandTree return HandleConfigCommand(ctx); if (ctx.Match("serverconfig", "guildconfig", "scfg")) return HandleServerConfigCommand(ctx); - if (ctx.Match("token")) - if (ctx.Match("refresh", "renew", "invalidate", "reroll", "regen")) - return ctx.Execute(TokenRefresh, m => m.RefreshToken(ctx)); - else - return ctx.Execute(TokenGet, m => m.GetToken(ctx)); if (ctx.Match("import")) return ctx.Execute(Import, m => m.Import(ctx)); if (ctx.Match("export")) diff --git a/crates/command_definitions/src/api.rs b/crates/command_definitions/src/api.rs index 8b137891..e9cd5746 100644 --- a/crates/command_definitions/src/api.rs +++ b/crates/command_definitions/src/api.rs @@ -1 +1,9 @@ +use super::*; +pub fn cmds() -> impl Iterator { + [ + command!("token" => "token_display"), + command!("token", ("refresh", ["renew", "regen", "reroll"]) => "token_refresh"), + ] + .into_iter() +} diff --git a/crates/command_definitions/src/lib.rs b/crates/command_definitions/src/lib.rs index ceb05a49..df197cbd 100644 --- a/crates/command_definitions/src/lib.rs +++ b/crates/command_definitions/src/lib.rs @@ -31,6 +31,7 @@ pub fn all() -> impl Iterator { .chain(fun::cmds()) .chain(switch::cmds()) .chain(random::cmds()) + .chain(api::cmds()) .map(|cmd| { cmd.hidden_flag(("plaintext", ["pt"])) .hidden_flag(("raw", ["r"]))