aboutsummaryrefslogtreecommitdiff
path: root/src/model/channel/guild_channel.rs
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/model/channel/guild_channel.rs
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/model/channel/guild_channel.rs')
-rw-r--r--src/model/channel/guild_channel.rs34
1 files changed, 15 insertions, 19 deletions
diff --git a/src/model/channel/guild_channel.rs b/src/model/channel/guild_channel.rs
index 54f802d..9b8371d 100644
--- a/src/model/channel/guild_channel.rs
+++ b/src/model/channel/guild_channel.rs
@@ -1,5 +1,5 @@
use chrono::{DateTime, FixedOffset};
-use model::*;
+use model::prelude::*;
#[cfg(all(feature = "cache", feature = "model"))]
use CACHE;
@@ -137,18 +137,17 @@ impl GuildChannel {
/// permissions:
///
/// ```rust,no_run
- /// # use serenity::model::{ChannelId, Permissions, UserId};
+ /// # use serenity::model::id::{ChannelId, UserId};
/// # use std::error::Error;
/// #
/// # fn try_main() -> Result<(), Box<Error>> {
/// # let (channel_id, user_id) = (ChannelId(0), UserId(0));
/// #
- /// use serenity::model::{
- /// ModelError,
+ /// use serenity::model::channel::{
/// PermissionOverwrite,
/// PermissionOverwriteType,
- /// permissions,
/// };
+ /// use serenity::model::{ModelError, Permissions};
/// use serenity::CACHE;
///
/// let allow = Permissions::SEND_MESSAGES;
@@ -179,18 +178,17 @@ impl GuildChannel {
/// permissions:
///
/// ```rust,no_run
- /// # use serenity::model::{ChannelId, Permissions, UserId};
+ /// # use serenity::model::id::{ChannelId, UserId};
/// # use std::error::Error;
/// #
/// # fn try_main() -> Result<(), Box<Error>> {
/// # let (channel_id, user_id) = (ChannelId(0), UserId(0));
/// #
- /// use serenity::model::{
- /// ModelError,
+ /// use serenity::model::channel::{
/// PermissionOverwrite,
/// PermissionOverwriteType,
- /// permissions,
/// };
+ /// use serenity::model::{ModelError, Permissions};
/// use serenity::CACHE;
///
/// let allow = Permissions::SEND_MESSAGES;
@@ -425,7 +423,7 @@ impl GuildChannel {
///
/// ```rust,no_run
/// use serenity::prelude::*;
- /// use serenity::model::*;
+ /// use serenity::model::prelude::*;
/// struct Handler;
///
/// use serenity::CACHE;
@@ -452,10 +450,9 @@ impl GuildChannel {
/// for demonstrative purposes):
///
/// ```rust,no_run
- /// use serenity::prelude::*;
- /// use serenity::model::*;
/// use serenity::CACHE;
- /// use serenity::model::permissions;
+ /// use serenity::prelude::*;
+ /// use serenity::model::prelude::*;
/// use std::fs::File;
///
/// struct Handler;
@@ -468,11 +465,10 @@ impl GuildChannel {
/// };
///
/// let current_user_id = CACHE.read().user.id;
- /// let permissions =
- /// channel.read().permissions_for(current_user_id).unwrap();
+ /// let permissions =
+ /// channel.read().permissions_for(current_user_id).unwrap();
///
- /// if !permissions.contains(Permissions::ATTACH_FILES |
- /// Permissions::SEND_MESSAGES) {
+ /// if !permissions.contains(Permissions::ATTACH_FILES | Permissions::SEND_MESSAGES) {
/// return;
/// }
///
@@ -485,8 +481,8 @@ impl GuildChannel {
/// },
/// };
///
- /// let _ = msg.channel_id.send_files(vec![(&file, "cat.png")], |m|
- /// m.content("here's a cat"));
+ /// let _ = msg.channel_id.send_files(vec![(&file, "cat.png")], |m|
+ /// m.content("here's a cat"));
/// }
/// }
///