mirror of
https://github.com/MedzikUser/servers
synced 2024-08-14 23:57:48 +00:00
3fb0a1132a
- 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
32 lines
632 B
Rust
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(())
|
|
}
|
|
}
|