aboutsummaryrefslogtreecommitdiff
path: root/src/framework/standard/command.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/framework/standard/command.rs')
-rw-r--r--src/framework/standard/command.rs23
1 files changed, 10 insertions, 13 deletions
diff --git a/src/framework/standard/command.rs b/src/framework/standard/command.rs
index b53ed90..be7ec2a 100644
--- a/src/framework/standard/command.rs
+++ b/src/framework/standard/command.rs
@@ -9,12 +9,9 @@ pub type Check = Fn(&mut Context, &Message, &mut Args, &Arc<Command>) -> bool
+ Send
+ Sync
+ 'static;
-pub type Exec = Fn(&mut Context, &Message, Args) -> Result<(), Error> + Send + Sync + 'static;
-pub type Help = Fn(&mut Context, &Message, HashMap<String, Arc<CommandGroup>>, Args)
- -> Result<(), Error>
- + Send
- + Sync
- + 'static;
+pub type Exec = fn(&mut Context, &Message, Args) -> Result<(), Error>;
+pub type Help = fn(&mut Context, &Message, HashMap<String, Arc<CommandGroup>>, Args)
+ -> Result<(), Error>;
pub type BeforeHook = Fn(&mut Context, &Message, &str) -> bool + Send + Sync + 'static;
pub type AfterHook = Fn(&mut Context, &Message, &str, Result<(), Error>) + Send + Sync + 'static;
pub(crate) type InternalCommand = Arc<Command>;
@@ -40,8 +37,8 @@ impl<D: fmt::Display> From<D> for Error {
/// your commands.
pub enum CommandType {
StringResponse(String),
- Basic(Box<Exec>),
- WithCommands(Box<Help>),
+ Basic(Exec),
+ WithCommands(Help),
}
pub struct CommandGroup {
@@ -88,14 +85,14 @@ pub struct Command {
pub guild_only: bool,
/// Whether command can only be used by owners or not.
pub owners_only: bool,
- pub(crate) aliases: Vec<String>,
+ /// Other names that can be used to call this command instead.
+ pub aliases: Vec<String>,
}
impl Command {
- pub fn new<F>(f: F) -> Self
- where F: Fn(&mut Context, &Message, Args) -> Result<(), Error> + Send + Sync + 'static {
+ pub fn new(f: fn(&mut Context, &Message, Args) -> Result<(), Error>) -> Self {
Command {
- exec: CommandType::Basic(Box::new(f)),
+ exec: CommandType::Basic(f),
..Command::default()
}
}
@@ -106,7 +103,7 @@ impl Default for Command {
Command {
aliases: Vec::new(),
checks: Vec::default(),
- exec: CommandType::Basic(Box::new(|_, _, _| Ok(()))),
+ exec: CommandType::Basic(|_, _, _| Ok(())),
desc: None,
usage: None,
example: None,