aboutsummaryrefslogtreecommitdiff
path: root/src/framework
diff options
context:
space:
mode:
authorZeyla Hellyer <[email protected]>2017-12-16 08:39:36 -0800
committerZeyla Hellyer <[email protected]>2017-12-16 08:45:26 -0800
commitbcd16dddb8cc3086a13524c79676f3a8bebbc524 (patch)
tree42d254fb4738df957c4b7d9e5766d1cb5bd47323 /src/framework
parentFix guild deserialization tests (diff)
downloadserenity-bcd16dddb8cc3086a13524c79676f3a8bebbc524.tar.xz
serenity-bcd16dddb8cc3086a13524c79676f3a8bebbc524.zip
Break up the model module
The `model` module has historically been one giant module re-exporting all of the model types, which is somewhere around 100 types. This can be a lot to look at for a new user and somewhat overwhelming, especially with a large number of fine-grained imports from the module. The module is now neatly split up into submodules, mostly like it has been internally since the early versions of the library. The submodules are: - application - channel - error - event - gateway - guild - id - invite - misc - permissions - prelude - user - voice - webhook Each submodule contains types that are "owned" by the module. For example, the `guild` submodule contains, but not limited to, Emoji, AuditLogsEntry, Role, and Member. `channel` contains, but not limited to, Attachment, Embed, Message, and Reaction. Upgrade path: Instead of glob importing the models via `use serenity::model::*;`, instead glob import via the prelude: ```rust use serenity::model::prelude::*; ``` Instead of importing from the root model module: ```rust use serenity::model::{Guild, Message, OnlineStatus, Role, User}; ``` instead import from the submodules like so: ```rust use serenity::model::channel::Message; use serenity::model::guild::{Guild, Role}; use serenity::model::user::{OnlineStatus, User}; ```
Diffstat (limited to 'src/framework')
-rw-r--r--src/framework/mod.rs4
-rw-r--r--src/framework/standard/buckets.rs2
-rw-r--r--src/framework/standard/command.rs3
-rw-r--r--src/framework/standard/configuration.rs11
-rw-r--r--src/framework/standard/create_command.rs5
-rw-r--r--src/framework/standard/create_group.rs3
-rw-r--r--src/framework/standard/help_commands.rs3
-rw-r--r--src/framework/standard/mod.rs16
8 files changed, 27 insertions, 20 deletions
diff --git a/src/framework/mod.rs b/src/framework/mod.rs
index c5ddb04..9f72dc6 100644
--- a/src/framework/mod.rs
+++ b/src/framework/mod.rs
@@ -61,11 +61,11 @@ pub mod standard;
pub use self::standard::StandardFramework;
use client::Context;
-use model::Message;
+use model::channel::Message;
use threadpool::ThreadPool;
#[cfg(feature = "standard_framework")]
-use model::UserId;
+use model::id::UserId;
/// This trait allows for serenity to either use its builtin framework, or yours.
pub trait Framework {
diff --git a/src/framework/standard/buckets.rs b/src/framework/standard/buckets.rs
index 60316b1..c29805f 100644
--- a/src/framework/standard/buckets.rs
+++ b/src/framework/standard/buckets.rs
@@ -1,6 +1,6 @@
use chrono::Utc;
use client::Context;
-use model::{ChannelId, GuildId, UserId};
+use model::id::{ChannelId, GuildId, UserId};
use std::collections::HashMap;
use std::default::Default;
diff --git a/src/framework/standard/command.rs b/src/framework/standard/command.rs
index d010f92..be0196c 100644
--- a/src/framework/standard/command.rs
+++ b/src/framework/standard/command.rs
@@ -1,5 +1,6 @@
use client::Context;
-use model::{Message, Permissions};
+use model::channel::Message;
+use model::Permissions;
use std::collections::HashMap;
use std::fmt;
use std::fmt::{Debug, Formatter};
diff --git a/src/framework/standard/configuration.rs b/src/framework/standard/configuration.rs
index 23148e3..d54a821 100644
--- a/src/framework/standard/configuration.rs
+++ b/src/framework/standard/configuration.rs
@@ -1,6 +1,7 @@
use client::Context;
use http;
-use model::{GuildId, Message, UserId};
+use model::channel::Message;
+use model::id::{GuildId, UserId};
use std::collections::HashSet;
use std::default::Default;
use super::command::PrefixCheck;
@@ -101,7 +102,7 @@ impl Configuration {
/// #
/// # impl EventHandler for Handler {}
/// # let mut client = Client::new("token", Handler).unwrap();
- /// use serenity::model::GuildId;
+ /// use serenity::model::id::GuildId;
/// use serenity::framework::StandardFramework;
///
/// client.with_framework(StandardFramework::new().configure(|c| c
@@ -126,7 +127,7 @@ impl Configuration {
/// #
/// # impl EventHandler for Handler {}
/// # let mut client = Client::new("token", Handler).unwrap();
- /// use serenity::model::UserId;
+ /// use serenity::model::id::UserId;
/// use serenity::framework::StandardFramework;
///
/// client.with_framework(StandardFramework::new().configure(|c| c
@@ -287,7 +288,7 @@ impl Configuration {
/// #
/// # impl EventHandler for Handler {}
/// # let mut client = Client::new("token", Handler).unwrap();
- /// use serenity::model::UserId;
+ /// use serenity::model::id::UserId;
/// use serenity::framework::StandardFramework;
///
/// client.with_framework(StandardFramework::new().configure(|c| c
@@ -302,7 +303,7 @@ impl Configuration {
/// #
/// # impl EventHandler for Handler {}
/// # let mut client = Client::new("token", Handler).unwrap();
- /// use serenity::model::UserId;
+ /// use serenity::model::id::UserId;
/// use std::collections::HashSet;
/// use serenity::framework::StandardFramework;
///
diff --git a/src/framework/standard/create_command.rs b/src/framework/standard/create_command.rs
index 0df649d..6450b64 100644
--- a/src/framework/standard/create_command.rs
+++ b/src/framework/standard/create_command.rs
@@ -1,7 +1,8 @@
pub use super::{Args, Command, CommandGroup, CommandOptions, CommandError};
use client::Context;
-use model::{Message, Permissions};
+use model::channel::Message;
+use model::Permissions;
use std::sync::Arc;
pub enum FnOrCommand {
@@ -50,7 +51,7 @@ impl CreateCommand {
/// CommandError,
/// StandardFramework,
/// };
- /// use serenity::model::Message;
+ /// use serenity::model::channel::Message;
/// use std::env;
///
/// let token = env::var("DISCORD_TOKEN").unwrap();
diff --git a/src/framework/standard/create_group.rs b/src/framework/standard/create_group.rs
index 77fb348..986207a 100644
--- a/src/framework/standard/create_group.rs
+++ b/src/framework/standard/create_group.rs
@@ -5,7 +5,8 @@ pub use super::create_command::{CreateCommand, FnOrCommand};
pub use super::Args;
use client::Context;
-use model::{Message, Permissions};
+use model::channel::Message;
+use model::Permissions;
use std::sync::Arc;
/// Used to create command groups
diff --git a/src/framework/standard/help_commands.rs b/src/framework/standard/help_commands.rs
index b2fc9f5..85debc4 100644
--- a/src/framework/standard/help_commands.rs
+++ b/src/framework/standard/help_commands.rs
@@ -25,7 +25,8 @@
use client::Context;
use framework::standard::{has_correct_roles, has_correct_permissions};
-use model::{ChannelId, Message};
+use model::channel::Message;
+use model::id::ChannelId;
use std::collections::HashMap;
use std::sync::Arc;
use std::fmt::Write;
diff --git a/src/framework/standard/mod.rs b/src/framework/standard/mod.rs
index 6f7e180..576f820 100644
--- a/src/framework/standard/mod.rs
+++ b/src/framework/standard/mod.rs
@@ -21,8 +21,10 @@ pub use self::create_group::CreateGroup;
use client::Context;
use internal::RwLockExt;
-use model::{ChannelId, GuildId, Guild, Member, Message, UserId};
-use model::permissions::Permissions;
+use model::channel::Message;
+use model::guild::{Guild, Member};
+use model::id::{ChannelId, GuildId, UserId};
+use model::Permissions;
use self::command::{AfterHook, BeforeHook};
use std::collections::HashMap;
use std::default::Default;
@@ -33,7 +35,7 @@ use threadpool::ThreadPool;
#[cfg(feature = "cache")]
use client::CACHE;
#[cfg(feature = "cache")]
-use model::Channel;
+use model::channel::Channel;
/// A macro to generate "named parameters". This is useful to avoid manually
/// using the "arguments" parameter and manually parsing types.
@@ -77,7 +79,7 @@ macro_rules! command {
impl $crate::framework::standard::Command for $fname {
#[allow(unreachable_code, unused_mut)]
fn execute(&self, mut $c: &mut $crate::client::Context,
- _: &$crate::model::Message,
+ _: &$crate::model::channel::Message,
_: $crate::framework::standard::Args)
-> ::std::result::Result<(), $crate::framework::standard::CommandError> {
@@ -94,7 +96,7 @@ macro_rules! command {
impl $crate::framework::standard::Command for $fname {
#[allow(unreachable_code, unused_mut)]
fn execute(&self, mut $c: &mut $crate::client::Context,
- $m: &$crate::model::Message,
+ $m: &$crate::model::channel::Message,
_: $crate::framework::standard::Args)
-> ::std::result::Result<(), $crate::framework::standard::CommandError> {
@@ -111,7 +113,7 @@ macro_rules! command {
impl $crate::framework::standard::Command for $fname {
#[allow(unreachable_code, unused_mut)]
fn execute(&self, mut $c: &mut $crate::client::Context,
- $m: &$crate::model::Message,
+ $m: &$crate::model::channel::Message,
mut $a: $crate::framework::standard::Args)
-> ::std::result::Result<(), $crate::framework::standard::CommandError> {
@@ -1098,4 +1100,4 @@ impl fmt::Display for HelpBehaviour {
HelpBehaviour::Nothing => write!(f, "HelBehaviour::Nothing"),
}
}
-} \ No newline at end of file
+}