refactor: add append_command macro
This commit is contained in:
parent
e333e401f3
commit
f41e012f8e
36
src/main.rs
36
src/main.rs
|
@ -46,6 +46,16 @@ fn logs() {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
macro_rules! append_command {
|
||||||
|
($branch:expr, $($command:expr), *) => {
|
||||||
|
$($branch
|
||||||
|
.message
|
||||||
|
.register($command)
|
||||||
|
.filter(Command::one(stringify!($command)));
|
||||||
|
)*
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() {
|
async fn main() {
|
||||||
logs();
|
logs();
|
||||||
|
@ -70,30 +80,8 @@ async fn main() {
|
||||||
let mut admin_commands = Router::new("admin_commands");
|
let mut admin_commands = Router::new("admin_commands");
|
||||||
let mut default_commands = Router::new("default_commands");
|
let mut default_commands = Router::new("default_commands");
|
||||||
|
|
||||||
default_commands
|
append_command!(default_commands, help, privacy);
|
||||||
.message
|
append_command!(admin_commands, unmute, mute, ban);
|
||||||
.register(help)
|
|
||||||
.filter(Command::one("help"));
|
|
||||||
|
|
||||||
default_commands
|
|
||||||
.message
|
|
||||||
.register(privacy)
|
|
||||||
.filter(Command::one("privacy"));
|
|
||||||
|
|
||||||
admin_commands
|
|
||||||
.message
|
|
||||||
.register(unmute)
|
|
||||||
.filter(Command::one("unmute"));
|
|
||||||
|
|
||||||
admin_commands
|
|
||||||
.message
|
|
||||||
.register(mute)
|
|
||||||
.filter(Command::one("mute"));
|
|
||||||
|
|
||||||
admin_commands
|
|
||||||
.message
|
|
||||||
.register(ban)
|
|
||||||
.filter(Command::one("ban"));
|
|
||||||
|
|
||||||
admin_commands
|
admin_commands
|
||||||
.message
|
.message
|
||||||
|
|
Loading…
Reference in New Issue