| 529 | |
| 530 | #[test] |
| 531 | fn test_custom_command() { |
| 532 | struct PingCommand; |
| 533 | impl SlashCommand for PingCommand { |
| 534 | fn name(&self) -> &str { |
| 535 | "ping" |
| 536 | } |
| 537 | fn description(&self) -> &str { |
| 538 | "Pong!" |
| 539 | } |
| 540 | fn execute(&self, _args: &str, _ctx: &CommandContext) -> CommandOutput { |
| 541 | CommandOutput::text("pong") |
| 542 | } |
| 543 | } |
| 544 | |
| 545 | let mut reg = CommandRegistry::new(); |
| 546 | let before = reg.len(); |
| 547 | reg.register(Arc::new(PingCommand)); |
| 548 | assert_eq!(reg.len(), before + 1); |
| 549 | |
| 550 | let ctx = test_ctx(); |
| 551 | let out = reg.dispatch("/ping", &ctx).unwrap(); |
| 552 | assert_eq!(out.text, "pong"); |
| 553 | } |
| 554 | |
| 555 | #[test] |
| 556 | fn test_list_commands() { |