aboutsummaryrefslogtreecommitdiff
path: root/src/framework/standard/create_command.rs
diff options
context:
space:
mode:
authoracdenisSK <[email protected]>2017-09-23 23:16:26 +0200
committeracdenisSK <[email protected]>2017-09-23 23:16:26 +0200
commitab67c1dd60b5f49541815b2527e8a3cb7712e182 (patch)
treeb7d7f1d5c0342c80488972e4e0157dc964a9baea /src/framework/standard/create_command.rs
parentDowngrade sodiumoxide to v0.0.14 (diff)
downloadserenity-ab67c1dd60b5f49541815b2527e8a3cb7712e182.tar.xz
serenity-ab67c1dd60b5f49541815b2527e8a3cb7712e182.zip
Revamp errors in `Args` and commands
Diffstat (limited to 'src/framework/standard/create_command.rs')
-rw-r--r--src/framework/standard/create_command.rs30
1 files changed, 4 insertions, 26 deletions
diff --git a/src/framework/standard/create_command.rs b/src/framework/standard/create_command.rs
index 30ef491..a6068da 100644
--- a/src/framework/standard/create_command.rs
+++ b/src/framework/standard/create_command.rs
@@ -1,7 +1,6 @@
-pub use super::{Args, Command, CommandGroup, CommandType};
+pub use super::{Args, Command, CommandGroup, CommandType, CommandError};
use std::collections::HashMap;
-use std::default::Default;
use std::sync::Arc;
use client::Context;
use model::{Message, Permissions};
@@ -103,7 +102,7 @@ impl CreateCommand {
///
/// [`exec_str`]: #method.exec_str
pub fn exec<F>(mut self, func: F) -> Self
- where F: Fn(&mut Context, &Message, Args) -> Result<(), String> + Send + Sync + 'static {
+ where F: Fn(&mut Context, &Message, Args) -> Result<(), CommandError> + Send + Sync + 'static {
self.0.exec = CommandType::Basic(Box::new(func));
self
@@ -113,10 +112,10 @@ impl CreateCommand {
/// the internal HashMap of commands, used specifically for creating a help
/// command.
///
- /// You can return `Err(string)` if there's an error.
+ /// You can return `Err(Custom(string))` if there's an error.
pub fn exec_help<F>(mut self, f: F) -> Self
where F: Fn(&mut Context, &Message, HashMap<String, Arc<CommandGroup>>, Args)
- -> Result<(), String>
+ -> Result<(), CommandError>
+ Send
+ Sync
+ 'static {
@@ -215,24 +214,3 @@ impl CreateCommand {
}
}
-impl Default for Command {
- fn default() -> Command {
- Command {
- aliases: Vec::new(),
- checks: Vec::default(),
- exec: CommandType::Basic(Box::new(|_, _, _| Ok(()))),
- desc: None,
- usage: None,
- example: None,
- min_args: None,
- bucket: None,
- max_args: None,
- required_permissions: Permissions::empty(),
- dm_only: false,
- guild_only: false,
- help_available: true,
- owners_only: false,
- allowed_roles: Vec::new(),
- }
- }
-}