aboutsummaryrefslogtreecommitdiff
path: root/azalea/examples/testbot/main.rs
diff options
context:
space:
mode:
authormat <git@matdoes.dev>2026-05-06 18:38:23 -0545
committermat <git@matdoes.dev>2026-05-07 08:05:58 -1200
commitcabc8b60a729ba17f5b75f7a7956c6d1ddcc8919 (patch)
tree237fd12a9768fe7431ce42dfbdde60f4c7850e06 /azalea/examples/testbot/main.rs
parent9ffd0e80bbb3feace231553d6539124585b03e3c (diff)
downloadazalea-drasl-cabc8b60a729ba17f5b75f7a7956c6d1ddcc8919.tar.xz
azalea-brigadier now allows commands to return a Result
Diffstat (limited to 'azalea/examples/testbot/main.rs')
-rw-r--r--azalea/examples/testbot/main.rs17
1 files changed, 13 insertions, 4 deletions
diff --git a/azalea/examples/testbot/main.rs b/azalea/examples/testbot/main.rs
index 806780b7..7778463c 100644
--- a/azalea/examples/testbot/main.rs
+++ b/azalea/examples/testbot/main.rs
@@ -126,7 +126,7 @@ impl State {
#[derive(Clone, Default, Resource)]
struct SwarmState {
pub args: Arc<Args>,
- pub commands: Arc<CommandDispatcher<Mutex<CommandSource>>>,
+ pub commands: Arc<commands::Dispatcher>,
}
async fn handle(bot: Client, event: azalea::Event, state: State) -> eyre::Result<()> {
@@ -137,7 +137,7 @@ async fn handle(bot: Client, event: azalea::Event, state: State) -> eyre::Result
bot.set_client_information(ClientInformation {
view_distance: 32,
..Default::default()
- });
+ })?;
if swarm.args.pathfinder_debug_particles {
bot.ecs
.write()
@@ -169,7 +169,16 @@ async fn handle(bot: Client, event: azalea::Event, state: State) -> eyre::Result
state: state.clone(),
}),
) {
- Ok(_) => {}
+ Ok(Ok(_)) => {}
+ Ok(Err(err)) => {
+ eprintln!("azalea error: {err:?}");
+ let command_source = CommandSource {
+ bot,
+ chat: chat.clone(),
+ state: state.clone(),
+ };
+ command_source.reply(format!("azalea error: {err:?}"));
+ }
Err(err) => {
eprintln!("{err:?}");
let command_source = CommandSource {
@@ -200,7 +209,7 @@ async fn handle(bot: Client, event: azalea::Event, state: State) -> eyre::Result
.max_timeout(Duration::from_secs(1)),
);
} else {
- following.look_at();
+ following.look_at()?;
}
}
}