use crate::context::{BotContext, MessageContext};
use async_trait::async_trait;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum HandlerAction {
Done,
Continue,
}
impl HandlerAction {
pub const fn done() -> HandlerResult {
Ok(HandlerAction::Done)
}
}
impl From<()> for HandlerAction {
fn from(_: ()) -> Self {
HandlerAction::Done
}
}
pub type HandlerResult = Result<HandlerAction, Box<dyn std::error::Error + Send + Sync>>;
#[derive(Debug, Clone)]
pub struct Command {
pub name: &'static str,
pub description: Option<&'static str>,
pub args: Vec<&'static str>,
pub rank: u64,
}
#[async_trait]
pub trait CommandBuilder: Send + Sync + 'static {
fn name(&self) -> &'static str;
fn description(&self) -> Option<&'static str>;
fn args(&self) -> Vec<&'static str>;
fn rank(&self) -> u64;
async fn run(&self, bot: &BotContext, ev: &MessageContext) -> HandlerResult;
}