aboutsummaryrefslogtreecommitdiff
path: root/src/framework
diff options
context:
space:
mode:
authorZeyla Hellyer <[email protected]>2017-05-24 07:44:46 -0700
committerZeyla Hellyer <[email protected]>2017-05-24 17:31:48 -0700
commit75749ac3f894a2a41b54287a7e7c9114152c99e4 (patch)
tree7a2e6aa27ce8e37a6a80c95fddf7d14adea1a333 /src/framework
parentMove Reaction struct into its proper place (diff)
downloadserenity-75749ac3f894a2a41b54287a7e7c9114152c99e4.tar.xz
serenity-75749ac3f894a2a41b54287a7e7c9114152c99e4.zip
Re-order methods/fields in the framework
This will help with readability in the generated documentation.
Diffstat (limited to 'src/framework')
-rw-r--r--src/framework/buckets.rs4
-rw-r--r--src/framework/configuration.rs68
-rw-r--r--src/framework/create_command.rs28
3 files changed, 50 insertions, 50 deletions
diff --git a/src/framework/buckets.rs b/src/framework/buckets.rs
index 02cd658..eea1253 100644
--- a/src/framework/buckets.rs
+++ b/src/framework/buckets.rs
@@ -10,17 +10,17 @@ pub struct Ratelimit {
#[doc(hidden)]
pub struct MemberRatelimit {
- pub tickets: i32,
pub last_time: i64,
pub set_time: i64,
+ pub tickets: i32,
}
impl Default for MemberRatelimit {
fn default() -> Self {
MemberRatelimit {
- tickets: 0,
last_time: 0,
set_time: 0,
+ tickets: 0,
}
}
}
diff --git a/src/framework/configuration.rs b/src/framework/configuration.rs
index c104e1e..0561f87 100644
--- a/src/framework/configuration.rs
+++ b/src/framework/configuration.rs
@@ -29,37 +29,35 @@ use ::model::{GuildId, UserId};
/// [`Framework`]: struct.Framework.html
pub struct Configuration {
#[doc(hidden)]
- pub depth: usize,
- #[doc(hidden)]
- pub on_mention: Option<Vec<String>>,
+ pub allow_dm: bool,
#[doc(hidden)]
pub allow_whitespace: bool,
#[doc(hidden)]
- pub prefixes: Vec<String>,
+ pub blocked_guilds: HashSet<GuildId>,
+ #[doc(hidden)]
+ pub blocked_users: HashSet<UserId>,
+ #[doc(hidden)]
+ pub depth: usize,
+ #[doc(hidden)]
+ pub disabled_commands: HashSet<String>,
#[doc(hidden)]
pub dynamic_prefix: Option<Box<PrefixCheck>>,
#[doc(hidden)]
pub ignore_bots: bool,
#[doc(hidden)]
- pub blocked_users: HashSet<UserId>,
+ pub ignore_webhooks: bool,
#[doc(hidden)]
- pub blocked_guilds: HashSet<GuildId>,
+ pub on_mention: Option<Vec<String>>,
#[doc(hidden)]
pub owners: HashSet<UserId>,
#[doc(hidden)]
- pub disabled_commands: HashSet<String>,
- #[doc(hidden)]
- pub allow_dm: bool,
- #[doc(hidden)]
- pub ignore_webhooks: bool,
+ pub prefixes: Vec<String>,
}
impl Configuration {
- /// Whether the bot should respond to other bots.
- ///
- /// For example, if this is set to false, then the bot will respond to any other bots including itself.
- pub fn ignore_bots(mut self, ignore_bots: bool) -> Self {
- self.ignore_bots = ignore_bots;
+ /// If set to false, bot will ignore any private messages.
+ pub fn allow_dm(mut self, allow_dm: bool) -> Self {
+ self.allow_dm = allow_dm;
self
}
@@ -94,17 +92,9 @@ impl Configuration {
self
}
- /// If set to false, bot will ignore any private messages.
- pub fn allow_dm(mut self, allow_dm: bool) -> Self {
- self.allow_dm = allow_dm;
-
- self
- }
-
- /// If set to true, bot will ignore all commands called by webhooks.
- /// True by default.
- pub fn ignore_webhooks(mut self, ignore_webhooks: bool) -> Self {
- self.ignore_webhooks = ignore_webhooks;
+ /// HashSet of guild Ids where commands will be ignored.
+ pub fn blocked_guilds(mut self, guilds: HashSet<GuildId>) -> Self {
+ self.blocked_guilds = guilds;
self
}
@@ -117,13 +107,6 @@ impl Configuration {
self
}
- /// HashSet of guild Ids where commands will be ignored.
- pub fn blocked_guilds(mut self, guilds: HashSet<GuildId>) -> Self {
- self.blocked_guilds = guilds;
-
- self
- }
-
/// The default depth of the message to check for commands. Defaults to 5.
/// This determines how "far" into a message to check for a valid command.
///
@@ -176,6 +159,23 @@ impl Configuration {
self
}
+ /// Whether the bot should respond to other bots.
+ ///
+ /// For example, if this is set to false, then the bot will respond to any other bots including itself.
+ pub fn ignore_bots(mut self, ignore_bots: bool) -> Self {
+ self.ignore_bots = ignore_bots;
+
+ self
+ }
+
+ /// If set to true, bot will ignore all commands called by webhooks.
+ /// True by default.
+ pub fn ignore_webhooks(mut self, ignore_webhooks: bool) -> Self {
+ self.ignore_webhooks = ignore_webhooks;
+
+ self
+ }
+
/// Whether or not to respond to commands initiated with a mention. Note
/// that this can be used in conjunction with [`prefix`].
///
diff --git a/src/framework/create_command.rs b/src/framework/create_command.rs
index 512e82c..a31c91a 100644
--- a/src/framework/create_command.rs
+++ b/src/framework/create_command.rs
@@ -9,20 +9,6 @@ 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 an alias, allowing users to use the command under a different name.
- pub fn known_as(mut self, name: &str) -> Self {
- self.0.aliases.push(name.to_owned());
-
- self
- }
-
/// Adds multiple aliases.
pub fn batch_known_as(mut self, names: Vec<&str>) -> Self {
for n in names {
@@ -32,6 +18,13 @@ impl CreateCommand {
self
}
+ /// 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.
///
@@ -149,6 +142,13 @@ impl CreateCommand {
self
}
+ /// Adds an alias, allowing users to use the command under a different name.
+ pub fn known_as(mut self, name: &str) -> Self {
+ self.0.aliases.push(name.to_owned());
+
+ 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);