aboutsummaryrefslogtreecommitdiff
path: root/azalea/examples/echo.rs
diff options
context:
space:
mode:
Diffstat (limited to 'azalea/examples/echo.rs')
-rw-r--r--azalea/examples/echo.rs13
1 files changed, 5 insertions, 8 deletions
diff --git a/azalea/examples/echo.rs b/azalea/examples/echo.rs
index a5280d8b..07dd50c1 100644
--- a/azalea/examples/echo.rs
+++ b/azalea/examples/echo.rs
@@ -12,7 +12,7 @@ async fn main() {
azalea::start(azalea::Options {
account,
address: "localhost",
- state: Arc::new(Mutex::new(State::default())),
+ state: State::default(),
plugins: vec![],
handle,
})
@@ -20,19 +20,16 @@ async fn main() {
.unwrap();
}
+#[derive(Default, Clone)]
pub struct State {}
-async fn handle(bot: Client, event: Arc<Event>, state: Arc<Mutex<State>>) -> anyhow::Result<()> {
- match *event {
+async fn handle(bot: Client, event: Event, state: State) -> anyhow::Result<()> {
+ match event {
Event::Chat(m) => {
if m.username == bot.username {
return Ok(()); // ignore our own messages
};
- bot.chat(m.message).await;
- }
- Event::Kick(m) => {
- println!(m);
- bot.reconnect().await.unwrap();
+ bot.chat(m.content).await;
}
_ => {}
}