aboutsummaryrefslogtreecommitdiff
path: root/src/model/id.rs
diff options
context:
space:
mode:
authorIllia <[email protected]>2016-12-10 22:25:55 +0200
committerzeyla <[email protected]>2016-12-10 12:25:55 -0800
commite44838f4339b90817b5eba5df16230b02487f0cc (patch)
tree8513ab3d9d3f9c8826f85630524cca1e4a7e188d /src/model/id.rs
parentFix no-cache+method conditional compiles (diff)
downloadserenity-e44838f4339b90817b5eba5df16230b02487f0cc.tar.xz
serenity-e44838f4339b90817b5eba5df16230b02487f0cc.zip
More config for CreateCommand, add various methods
Adds multiple configurations to the command builder, and adds methods to various structs. Context::get_current_user is a shortcut to retrieve the current user from the cache. Message::get_member retrieves the member object of the message, if sent in a guild. Message::is_private checks if the message was sent in a Group or PrivateChannel. User::member retrieves the user's member object in a guild by Id; Adds 6 configurations to the command builder: - dm_only: whether the command can only be used in direct messages; - guild_only: whether the command can only be used in guilds; - help_available: whether the command should be displayed in the help list; - max_args: specify the maximum number of arguments a command must be given; - min_args: specify the minimum number of arguments a command must be given; - required_permissions: the permissions a member must have to be able to use the command;
Diffstat (limited to 'src/model/id.rs')
-rw-r--r--src/model/id.rs16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/model/id.rs b/src/model/id.rs
index d0d0b61..0d337fb 100644
--- a/src/model/id.rs
+++ b/src/model/id.rs
@@ -1,16 +1,16 @@
use super::*;
use std::fmt;
-#[cfg(all(feature = "cache", feature = "methods"))]
+#[cfg(all(feature="cache", feature="methods"))]
use ::client::CACHE;
-#[cfg(feature = "methods")]
+#[cfg(feature="methods")]
use ::client::rest;
-#[cfg(feature = "methods")]
+#[cfg(feature="methods")]
use ::internal::prelude::*;
impl ChannelId {
/// Search the cache for the channel with the Id.
- #[cfg(all(feature = "cache", feature = "methods"))]
+ #[cfg(all(feature="cache", feature="methods"))]
pub fn find(&self) -> Option<Channel> {
CACHE.read().unwrap().get_channel(*self).map(|x| x.clone_inner())
}
@@ -73,7 +73,7 @@ impl From<Emoji> for EmojiId {
impl GuildId {
/// Search the cache for the guild.
- #[cfg(all(feature = "cache", feature="methods"))]
+ #[cfg(all(feature="cache", feature="methods"))]
pub fn find(&self) -> Option<Guild> {
CACHE.read().unwrap().get_guild(*self).cloned()
}
@@ -89,7 +89,7 @@ impl GuildId {
/// Returns this Id as a `ChannelId`, which is useful when needing to use
/// the guild Id to send a message to the default channel.
- #[cfg(feature = "methods")]
+ #[cfg(feature="methods")]
pub fn to_channel(&self) -> ChannelId {
ChannelId(self.0)
}
@@ -156,7 +156,7 @@ impl From<Role> for RoleId {
impl RoleId {
/// Search the cache for the role.
- #[cfg(all(feature = "cache", feature = "methods"))]
+ #[cfg(all(feature="cache", feature="methods"))]
pub fn find(&self) -> Option<Role> {
CACHE.read()
.unwrap()
@@ -174,7 +174,7 @@ impl RoleId {
impl UserId {
/// Search the cache for the channel with the Id.
- #[cfg(all(feature = "cache", feature = "methods"))]
+ #[cfg(all(feature="cache", feature="methods"))]
pub fn find(&self) -> Option<User> {
CACHE.read().unwrap().get_user(*self).cloned()
}