pub trait Command: Send + Sync {
// Required methods
fn name(&self) -> &str;
fn description(&self) -> &str;
fn execute(&self, args: &CommandArgs, ctx: &dyn Context);
}Expand description
A server command that can be executed by players or the console.
§Example
ⓘ
use basalt_api::command::Command;
use crate::context::Context;
pub struct PingCommand;
impl Command for PingCommand {
fn name(&self) -> &str { "ping" }
fn description(&self) -> &str { "Responds with pong" }
fn execute(&self, _args: &CommandArgs, ctx: &dyn Context) {
ctx.chat().send("Pong!");
}
}Required Methods§
Sourcefn description(&self) -> &str
fn description(&self) -> &str
A short description for the help listing.
Sourcefn execute(&self, args: &CommandArgs, ctx: &dyn Context)
fn execute(&self, args: &CommandArgs, ctx: &dyn Context)
Executes the command with parsed arguments.