diff --git a/src/main.rs b/src/main.rs index 3cacd3c..a602177 100644 --- a/src/main.rs +++ b/src/main.rs @@ -41,15 +41,6 @@ fn logs() { ); } -macro_rules! append_command { - ($branch:expr, $($command:expr), *) => { - $($branch - .message - .register($command) - .filter(Command::one(stringify!($command))); - )* - } -} #[tokio::main] async fn main() { @@ -75,8 +66,8 @@ async fn main() { let mut admin_commands = Router::new("admin_commands"); let mut default_commands = Router::new("default_commands"); - append_command!(default_commands, help, privacy); - append_command!(admin_commands, unmute, mute, ban); + create_handler!(default_commands, info_commands_endpoint, help, privacy); + create_handler!(admin_commands, admin_command_endpoint, mute, unmute, ban); admin_commands .message diff --git a/src/utils/macro_rules/create_handler.rs b/src/utils/macro_rules/create_handler.rs new file mode 100644 index 0000000..4f5109c --- /dev/null +++ b/src/utils/macro_rules/create_handler.rs @@ -0,0 +1,16 @@ +#[macro_export] +macro_rules! create_handler { + ($branch:expr, $command:expr) => { + $($branch + .message + .register($command) + .filter(Command::one(stringify!($command))); + )* + }; + ($branch:expr, $command:expr, $($endpoint:expr), *) => { + $branch + .message + .register($command) + .filter(Command::many([$(stringify!($endpoint)),*])); + }; +} diff --git a/src/utils/macro_rules/mod.rs b/src/utils/macro_rules/mod.rs new file mode 100644 index 0000000..5935e9e --- /dev/null +++ b/src/utils/macro_rules/mod.rs @@ -0,0 +1 @@ +pub mod create_handler;