aboutsummaryrefslogtreecommitdiff
path: root/src/model/channel/reaction.rs
diff options
context:
space:
mode:
authorZeyla Hellyer <[email protected]>2017-05-22 17:02:00 -0700
committerZeyla Hellyer <[email protected]>2017-05-22 17:02:00 -0700
commit9969be60cf320797c37b317da24d9a08fd5eafa5 (patch)
treef27bf7a57af95bbc11990b1edcea9cca99276964 /src/model/channel/reaction.rs
parentReasonably derive Debug on items (diff)
downloadserenity-9969be60cf320797c37b317da24d9a08fd5eafa5.tar.xz
serenity-9969be60cf320797c37b317da24d9a08fd5eafa5.zip
Restructure modules
Modules are now separated into a fashion where the library can be used for most use cases, without needing to compile the rest. The core of serenity, with no features enabled, contains only the struct (model) definitions, constants, and prelude. Models do not have most functions compiled in, as that is separated into the `model` feature. The `client` module has been split into 3 modules: `client`, `gateway`, and `http`. `http` contains functions to interact with the REST API. `gateway` contains the Shard to interact with the gateway, requiring `http` for retrieving the gateway URL. `client` requires both of the other features and acts as an abstracted interface over both the gateway and REST APIs, handling the event loop. The `builder` module has been separated from `utils`, and can now be optionally compiled in. It and the `http` feature are required by the `model` feature due to a large number of methods requiring access to them. `utils` now contains a number of utilities, such as the Colour struct, the `MessageBuilder`, and mention parsing functions. Each of the original `ext` modules are still featured, with `cache` not requiring any feature to be enabled, `framework` requiring the `client`, `model`, and `utils`, and `voice` requiring `gateway`. In total the features and their requirements are: - `builder`: none - `cache`: none - `client`: `gateway`, `http` - `framework`: `client`, `model`, `utils` - `gateway`: `http` - `http`: none - `model`: `builder`, `http` - `utils`: none - `voice`: `gateway` The default features are `builder`, `cache`, `client`, `framework`, `gateway`, `model`, `http`, and `utils`. To help with forwards compatibility, modules have been re-exported from their original locations.
Diffstat (limited to 'src/model/channel/reaction.rs')
-rw-r--r--src/model/channel/reaction.rs21
1 files changed, 12 insertions, 9 deletions
diff --git a/src/model/channel/reaction.rs b/src/model/channel/reaction.rs
index 9c3618d..132af7b 100644
--- a/src/model/channel/reaction.rs
+++ b/src/model/channel/reaction.rs
@@ -1,12 +1,14 @@
use serde::de::{Deserialize, Error as DeError, MapAccess, Visitor};
use std::fmt::{Display, Formatter, Result as FmtResult, Write as FmtWrite};
-use ::client::rest;
use ::internal::prelude::*;
use ::model::*;
#[cfg(feature="cache")]
-use ::client::CACHE;
+use ::CACHE;
+#[cfg(feature="model")]
+use ::http;
+#[cfg(feature="model")]
impl Reaction {
/// Deletes the reaction, but only if the current user is the user who made
/// the reaction or has permission to.
@@ -17,10 +19,10 @@ impl Reaction {
/// # Errors
///
/// If the `cache` is enabled, then returns a
- /// [`ClientError::InvalidPermissions`] if the current user does not have
+ /// [`ModelError::InvalidPermissions`] if the current user does not have
/// the required [permissions].
///
- /// [`ClientError::InvalidPermissions`]: ../client/enum.ClientError.html#variant.InvalidPermissions
+ /// [`ModelError::InvalidPermissions`]: enum.ModelError.html#variant.InvalidPermissions
/// [Manage Messages]: permissions/constant.MANAGE_MESSAGES.html
/// [permissions]: permissions
pub fn delete(&self) -> Result<()> {
@@ -41,7 +43,7 @@ impl Reaction {
let req = permissions::MANAGE_MESSAGES;
if !utils::user_has_perms(self.channel_id, req).unwrap_or(true) {
- return Err(Error::Client(ClientError::InvalidPermissions(req)));
+ return Err(Error::Model(ModelError::InvalidPermissions(req)));
}
}
@@ -50,7 +52,7 @@ impl Reaction {
Some(self.user_id.0)
}};
- rest::delete_reaction(self.channel_id.0,
+ http::delete_reaction(self.channel_id.0,
self.message_id.0,
user_id,
&self.emoji)
@@ -70,10 +72,10 @@ impl Reaction {
///
/// # Errors
///
- /// Returns a [`ClientError::InvalidPermissions`] if the current user does
+ /// Returns a [`ModelError::InvalidPermissions`] if the current user does
/// not have the required [permissions].
///
- /// [`ClientError::InvalidPermissions`]: ../client/enum.ClientError.html#variant.InvalidPermissions
+ /// [`ModelError::InvalidPermissions`]: enum.ModelError.html#variant.InvalidPermissions
/// [`Emoji`]: struct.Emoji.html
/// [`Message`]: struct.Message.html
/// [`User`]: struct.User.html
@@ -86,7 +88,7 @@ impl Reaction {
-> Result<Vec<User>>
where R: Into<ReactionType>,
U: Into<UserId> {
- rest::get_reaction_users(self.channel_id.0,
+ http::get_reaction_users(self.channel_id.0,
self.message_id.0,
&reaction_type.into(),
limit.unwrap_or(50),
@@ -201,6 +203,7 @@ impl<'de> Deserialize<'de> for ReactionType {
}
}
+#[cfg(any(feature="model", feature="http"))]
impl ReactionType {
/// Creates a data-esque display of the type. This is not very useful for
/// displaying, as the primary client can not render it, but can be useful