aboutsummaryrefslogtreecommitdiff
path: root/src/model/guild/mod.rs
diff options
context:
space:
mode:
authoracdenisSK <[email protected]>2017-10-03 16:55:58 +0200
committerZeyla Hellyer <[email protected]>2017-10-09 15:47:48 -0700
commit06dc6937bd3d4e5912de08e4ac3630a1f83b7f5a (patch)
treeeee16dc9d1c35e2b17a0a59d55cc85fa82726587 /src/model/guild/mod.rs
parentUse the de-generification trick. (diff)
downloadserenity-06dc6937bd3d4e5912de08e4ac3630a1f83b7f5a.tar.xz
serenity-06dc6937bd3d4e5912de08e4ac3630a1f83b7f5a.zip
Revert "Use the de-generification trick."
Makes the compiliation time just a bit worse
Diffstat (limited to 'src/model/guild/mod.rs')
-rw-r--r--src/model/guild/mod.rs30
1 files changed, 10 insertions, 20 deletions
diff --git a/src/model/guild/mod.rs b/src/model/guild/mod.rs
index da42a71..eef9d73 100644
--- a/src/model/guild/mod.rs
+++ b/src/model/guild/mod.rs
@@ -202,10 +202,6 @@ impl Guild {
/// [`User`]: struct.User.html
/// [Ban Members]: permissions/constant.BAN_MEMBERS.html
pub fn ban<U: Into<UserId>, BO: BanOptions>(&self, user: U, options: BO) -> Result<()> {
- self._ban(user.into(), options)
- }
-
- fn _ban<BO: BanOptions>(&self, user: UserId, options: BO) -> Result<()> {
#[cfg(feature = "cache")]
{
let req = Permissions::BAN_MEMBERS;
@@ -601,9 +597,7 @@ impl Guild {
///
/// Requires that the current user be in the guild.
#[inline]
- pub fn get<G: Into<GuildId>>(guild_id: G) -> Result<PartialGuild> { Self::_get(guild_id.into()) }
-
- fn _get(guild_id: GuildId) -> Result<PartialGuild> { guild_id.get() }
+ pub fn get<G: Into<GuildId>>(guild_id: G) -> Result<PartialGuild> { guild_id.into().get() }
/// Returns the formatted URL of the guild's icon, if one exists.
pub fn icon_url(&self) -> Option<String> {
@@ -760,15 +754,15 @@ impl Guild {
/// [`User`]: struct.User.html
pub fn permissions_for<C, U>(&self, channel_id: C, user_id: U) -> Permissions
where C: Into<ChannelId>, U: Into<UserId> {
- self._permissions_for(channel_id.into(), user_id.into())
- }
+ let user_id = user_id.into();
- fn _permissions_for(&self, ChannelId(cid): ChannelId, UserId(uid): UserId) -> Permissions {
// The owner has all permissions in all cases.
- if self.owner_id == uid {
+ if user_id == self.owner_id {
return Permissions::all();
}
+ let channel_id = channel_id.into();
+
// Start by retrieving the @everyone role's permissions.
let everyone = match self.roles.get(&RoleId(self.id.0)) {
Some(everyone) => everyone,
@@ -786,7 +780,7 @@ impl Guild {
// Create a base set of permissions, starting with `@everyone`s.
let mut permissions = everyone.permissions;
- let member = match self.members.get(&UserId(uid)) {
+ let member = match self.members.get(&user_id) {
Some(member) => member,
None => return everyone.permissions,
};
@@ -809,7 +803,7 @@ impl Guild {
return Permissions::all();
}
- if let Some(channel) = self.channels.get(&ChannelId(cid)) {
+ if let Some(channel) = self.channels.get(&channel_id) {
let channel = channel.read().unwrap();
// If this is a text channel, then throw out voice permissions.
@@ -842,7 +836,7 @@ impl Guild {
// Member
for overwrite in &channel.permission_overwrites {
- if PermissionOverwriteType::Member(UserId(uid)) != overwrite.kind {
+ if PermissionOverwriteType::Member(user_id) != overwrite.kind {
continue;
}
@@ -852,12 +846,12 @@ impl Guild {
warn!(
"(╯°□°)╯︵ ┻━┻ Guild {} does not contain channel {}",
self.id,
- cid
+ channel_id
);
}
// The default channel is always readable.
- if cid == self.id.0 {
+ if channel_id.0 == self.id.0 {
permissions |= Permissions::READ_MESSAGES;
}
@@ -1010,10 +1004,6 @@ impl Guild {
/// [`User`]: struct.User.html
/// [Ban Members]: permissions/constant.BAN_MEMBERS.html
pub fn unban<U: Into<UserId>>(&self, user_id: U) -> Result<()> {
- self._unban(user_id.into())
- }
-
- fn _unban(&self, user_id: UserId) -> Result<()> {
#[cfg(feature = "cache")]
{
let req = Permissions::BAN_MEMBERS;