aboutsummaryrefslogtreecommitdiff
path: root/src/ext/framework/create_command.rs
diff options
context:
space:
mode:
authorAustin Hellyer <[email protected]>2016-12-14 08:54:41 -0800
committerAustin Hellyer <[email protected]>2016-12-14 08:54:41 -0800
commitd9e585f008c26f1908982e75b0cdece73d1ade2c (patch)
tree9298a1f34ee9d7ab6c96123f48ec40e213eedbee /src/ext/framework/create_command.rs
parentDon't mutate token for bots on profile change (diff)
downloadserenity-d9e585f008c26f1908982e75b0cdece73d1ade2c.tar.xz
serenity-d9e585f008c26f1908982e75b0cdece73d1ade2c.zip
Slightly rework framework buckets
Diffstat (limited to 'src/ext/framework/create_command.rs')
-rw-r--r--src/ext/framework/create_command.rs87
1 files changed, 43 insertions, 44 deletions
diff --git a/src/ext/framework/create_command.rs b/src/ext/framework/create_command.rs
index e3faffd..7a1d744 100644
--- a/src/ext/framework/create_command.rs
+++ b/src/ext/framework/create_command.rs
@@ -4,12 +4,18 @@ use std::collections::HashMap;
use std::default::Default;
use std::sync::Arc;
use ::client::Context;
-use ::model::Message;
-use ::model::Permissions;
+use ::model::{Message, Permissions};
pub struct CreateCommand(pub Command);
impl CreateCommand {
+ /// Adds a ratelimit bucket.
+ pub fn bucket(mut self, bucket: &str) -> Self {
+ self.0.bucket = Some(bucket.to_owned());
+
+ self
+ }
+
/// Adds a "check" to a command, which checks whether or not the command's
/// function should be called.
///
@@ -57,20 +63,6 @@ impl CreateCommand {
self
}
- /// Adds a ratelimit bucket.
- pub fn bucket(mut self, bucket: &str) -> Self {
- self.0.bucket = Some(bucket.to_owned());
-
- self
- }
-
- /// Whether command should be displayed in help list or not, used by other commands.
- pub fn help_available(mut self, help_available: bool) -> Self {
- self.0.help_available = help_available;
-
- self
- }
-
/// Whether command can be used only privately or not.
pub fn dm_only(mut self, dm_only: bool) -> Self {
self.0.dm_only = dm_only;
@@ -78,34 +70,6 @@ impl CreateCommand {
self
}
- /// Whether command can be used only in guilds or not.
- pub fn guild_only(mut self, guild_only: bool) -> Self {
- self.0.guild_only = guild_only;
-
- self
- }
-
- /// Minumum amount of arguments that should be passed.
- pub fn min_args(mut self, min_args: i32) -> Self {
- self.0.min_args = Some(min_args);
-
- self
- }
-
- /// Maximum amount of arguments that can be passed.
- pub fn max_args(mut self, max_args: i32) -> Self {
- self.0.max_args = Some(max_args);
-
- self
- }
-
- /// Maximum amount of arguments that can be passed.
- pub fn required_permissions(mut self, required_permissions: Permissions) -> Self {
- self.0.required_permissions = required_permissions;
-
- self
- }
-
/// A function that can be called when a command is received.
/// You can return Err(string) if there's an error.
///
@@ -148,6 +112,41 @@ impl CreateCommand {
self
}
+ /// Whether command can be used only in guilds or not.
+ pub fn guild_only(mut self, guild_only: bool) -> Self {
+ self.0.guild_only = guild_only;
+
+ self
+ }
+
+ /// Whether command should be displayed in help list or not, used by other commands.
+ pub fn help_available(mut self, help_available: bool) -> Self {
+ self.0.help_available = help_available;
+
+ self
+ }
+
+ /// Maximum amount of arguments that can be passed.
+ pub fn max_args(mut self, max_args: i32) -> Self {
+ self.0.max_args = Some(max_args);
+
+ self
+ }
+
+ /// Minumum amount of arguments that should be passed.
+ pub fn min_args(mut self, min_args: i32) -> Self {
+ self.0.min_args = Some(min_args);
+
+ self
+ }
+
+ /// Maximum amount of arguments that can be passed.
+ pub fn required_permissions(mut self, required_permissions: Permissions) -> Self {
+ self.0.required_permissions = required_permissions;
+
+ self
+ }
+
/// Command usage schema, used by other commands.
pub fn usage(mut self, usage: &str) -> Self {
self.0.usage = Some(usage.to_owned());