servers/src/commands/disconnect.rs
MedzikUser 3fb0a1132a
chore: some changes (more in the commit description)
- added `/disconnect` commands
- moved logger init function to other file
- updated command description
- the `/help` command has been accelerated
- re-export `async_trait` so that it doesn't have to be added to dependencies in plugins
2022-07-29 21:55:21 +02:00

32 lines
632 B
Rust

use async_trait::async_trait;
use tokio::io::AsyncWriteExt;
use crate::{
plugins::{Command, PluginManagerType, Result},
tcp::Client,
};
pub struct CommandDisconnect;
#[async_trait]
impl Command for CommandDisconnect {
fn name(&self) -> &'static str {
"/disconnect"
}
fn help(&self) -> &'static str {
"Disconnect from the server"
}
async fn execute(
&self,
client: &mut Client,
_args: Vec<&str>,
_plugin_manager: &PluginManagerType,
) -> Result<()> {
// close the connection
client.stream.shutdown().await?;
Ok(())
}
}