From a9ff79a10553026b0fa32f0e31f1e0442467ca78 Mon Sep 17 00:00:00 2001 From: mat Date: Sun, 23 Oct 2022 14:46:06 -0500 Subject: write more documentation --- azalea/examples/craft_dig_straight_down.rs | 2 +- azalea/examples/echo.rs | 13 ++++--------- azalea/examples/pvp.rs | 3 +-- 3 files changed, 6 insertions(+), 12 deletions(-) (limited to 'azalea/examples') diff --git a/azalea/examples/craft_dig_straight_down.rs b/azalea/examples/craft_dig_straight_down.rs index 89b11021..48e1fd22 100644 --- a/azalea/examples/craft_dig_straight_down.rs +++ b/azalea/examples/craft_dig_straight_down.rs @@ -11,7 +11,7 @@ struct State { #[tokio::main] async fn main() { let account = Account::offline("bot"); - // or let bot = Account::microsoft("access token").await; + // or let bot = Account::microsoft("email").await; azalea::start(azalea::Options { account, diff --git a/azalea/examples/echo.rs b/azalea/examples/echo.rs index a5e27d56..a5280d8b 100644 --- a/azalea/examples/echo.rs +++ b/azalea/examples/echo.rs @@ -1,12 +1,13 @@ -use std::sync::Arc; +//! A simple bot that repeats chat messages sent by other players. use azalea::{Account, Client, Event}; use parking_lot::Mutex; +use std::sync::Arc; #[tokio::main] async fn main() { let account = Account::offline("bot"); - // or let account = Account::microsoft("access token").await; + // or let account = Account::microsoft("email").await; azalea::start(azalea::Options { account, @@ -22,7 +23,7 @@ async fn main() { pub struct State {} async fn handle(bot: Client, event: Arc, state: Arc>) -> anyhow::Result<()> { - match event { + match *event { Event::Chat(m) => { if m.username == bot.username { return Ok(()); // ignore our own messages @@ -33,12 +34,6 @@ async fn handle(bot: Client, event: Arc, state: Arc>) -> any println!(m); bot.reconnect().await.unwrap(); } - Event::HungerUpdate(h) => { - if !h.using_held_item() && h.hunger <= 17 { - bot.hold(azalea::ItemGroup::Food).await?; - bot.use_held_item().await?; - } - } _ => {} } diff --git a/azalea/examples/pvp.rs b/azalea/examples/pvp.rs index 9405cb6f..a2f070f0 100644 --- a/azalea/examples/pvp.rs +++ b/azalea/examples/pvp.rs @@ -1,7 +1,6 @@ -use std::sync::Arc; - use azalea::{pathfinder, Account, Accounts, Client, Event}; use parking_lot::Mutex; +use std::sync::Arc; #[tokio::main] async fn main() { -- cgit v1.2.3