aboutsummaryrefslogtreecommitdiff
path: root/azalea/examples/echo.rs
diff options
context:
space:
mode:
authormat <github@matdoes.dev>2022-10-23 14:46:06 -0500
committermat <github@matdoes.dev>2022-10-23 14:46:06 -0500
commita9ff79a10553026b0fa32f0e31f1e0442467ca78 (patch)
tree5ecda41c72d2202faeb70cda08aae0a9f1c17675 /azalea/examples/echo.rs
parent127126c2cc415887395f18119404ace362d4173a (diff)
downloadazalea-drasl-a9ff79a10553026b0fa32f0e31f1e0442467ca78.tar.xz
write more documentation
Diffstat (limited to 'azalea/examples/echo.rs')
-rw-r--r--azalea/examples/echo.rs13
1 files changed, 4 insertions, 9 deletions
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<Event>, state: Arc<Mutex<State>>) -> 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<Event>, state: Arc<Mutex<State>>) -> 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?;
- }
- }
_ => {}
}