diff options
| author | mat <github@matdoes.dev> | 2022-10-23 14:46:06 -0500 |
|---|---|---|
| committer | mat <github@matdoes.dev> | 2022-10-23 14:46:06 -0500 |
| commit | a9ff79a10553026b0fa32f0e31f1e0442467ca78 (patch) | |
| tree | 5ecda41c72d2202faeb70cda08aae0a9f1c17675 /azalea-client/src/chat.rs | |
| parent | 127126c2cc415887395f18119404ace362d4173a (diff) | |
| download | azalea-drasl-a9ff79a10553026b0fa32f0e31f1e0442467ca78.tar.xz | |
write more documentation
Diffstat (limited to 'azalea-client/src/chat.rs')
| -rw-r--r-- | azalea-client/src/chat.rs | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/azalea-client/src/chat.rs b/azalea-client/src/chat.rs index 6176357f..9e3d58a0 100644 --- a/azalea-client/src/chat.rs +++ b/azalea-client/src/chat.rs @@ -11,8 +11,9 @@ use crate::Client; impl Client { /// Sends chat message to the server. This only sends the chat packet and - /// not the command packet. The `chat` function handles checking whether - /// the message is a command and using the proper packet for you. + /// not the command packet. The [`Client::chat`] function handles checking whether + /// the message is a command and using the proper packet for you, so you + /// should use that instead. pub async fn send_chat_packet(&self, message: &str) -> Result<(), std::io::Error> { // TODO: chat signing let signature = sign_message(); @@ -54,6 +55,33 @@ impl Client { self.write_packet(packet).await } + /// Send a message in chat. + /// + /// # Examples + /// + /// ```rust,no_run + /// # use azalea::prelude::*; + /// # use parking_lot::Mutex; + /// # use std::sync::Arc; + /// # #[tokio::main] + /// # async fn main() { + /// # let account = Account::offline("bot"); + /// # azalea::start(azalea::Options { + /// # account, + /// # address: "localhost", + /// # state: Arc::new(Mutex::new(State::default())), + /// # plugins: vec![], + /// # handle, + /// # }) + /// # .await + /// # .unwrap(); + /// # } + /// # pub struct State {} + /// # async fn handle(bot: Client, event: Arc<Event>, state: Arc<Mutex<State>>) -> anyhow::Result<()> { + /// bot.chat("Hello, world!").await.unwrap(); + /// # Ok(()) + /// # } + /// ``` pub async fn chat(&self, message: &str) -> Result<(), std::io::Error> { if message.chars().next() == Some('/') { self.send_command_packet(&message[1..]).await |
