aboutsummaryrefslogtreecommitdiff
path: root/src/model/guild
diff options
context:
space:
mode:
authoracdenisSK <[email protected]>2017-10-24 18:10:10 +0200
committeracdenisSK <[email protected]>2017-10-24 18:10:10 +0200
commitef60c3cd5b93d61ff8200f5f6871b449bf7dccb5 (patch)
treeff9ec9e09dc363c05c6b582380a120ca47290a9f /src/model/guild
parentRemove `on_` prefix to EventHandler tymethods (diff)
parentFall back to `str::parse` if `parse_username` fails (diff)
downloadserenity-ef60c3cd5b93d61ff8200f5f6871b449bf7dccb5.tar.xz
serenity-ef60c3cd5b93d61ff8200f5f6871b449bf7dccb5.zip
Merge v0.4.2
Diffstat (limited to 'src/model/guild')
-rw-r--r--src/model/guild/guild_id.rs23
-rw-r--r--src/model/guild/mod.rs20
2 files changed, 42 insertions, 1 deletions
diff --git a/src/model/guild/guild_id.rs b/src/model/guild/guild_id.rs
index 2771fc8..7a851bb 100644
--- a/src/model/guild/guild_id.rs
+++ b/src/model/guild/guild_id.rs
@@ -110,7 +110,7 @@ impl GuildId {
pub fn create_channel(&self, name: &str, kind: ChannelType) -> Result<GuildChannel> {
let map = json!({
"name": name,
- "type": kind.name(),
+ "type": kind as u8,
});
http::create_channel(self.0, &map)
@@ -311,6 +311,27 @@ impl GuildId {
http::edit_role(self.0, role_id.into().0, &map)
}
+ /// Edits the order of [`Role`]s
+ /// Requires the [Manage Roles] permission.
+ ///
+ /// # Examples
+ ///
+ /// Change the order of a role:
+ ///
+ /// ```rust,ignore
+ /// use serenity::model::{GuildId, RoleId};
+ /// GuildId(7).edit_role_position(RoleId(8), 2);
+ /// ```
+ ///
+ /// [`Role`]: struct.Role.html
+ /// [Manage Roles]: permissions/constant.MANAGE_ROLES.html
+ #[inline]
+ pub fn edit_role_position<R>(&self, role_id: R, position: u64) -> Result<Vec<Role>>
+ where R: Into<RoleId> {
+ http::edit_role_position(self.0, role_id.into().0, position)
+ }
+
+
/// Search the cache for the guild.
#[cfg(feature = "cache")]
pub fn find(&self) -> Option<Arc<RwLock<Guild>>> { CACHE.read().guild(*self) }
diff --git a/src/model/guild/mod.rs b/src/model/guild/mod.rs
index a90445a..7aeb98f 100644
--- a/src/model/guild/mod.rs
+++ b/src/model/guild/mod.rs
@@ -600,6 +600,26 @@ impl Guild {
self.id.edit_role(role_id, f)
}
+ /// Edits the order of [`Role`]s
+ /// Requires the [Manage Roles] permission.
+ ///
+ /// # Examples
+ ///
+ /// Change the order of a role:
+ ///
+ /// ```rust,ignore
+ /// use serenity::model::RoleId;
+ /// guild.edit_role_position(RoleId(8), 2);
+ /// ```
+ ///
+ /// [`Role`]: struct.Role.html
+ /// [Manage Roles]: permissions/constant.MANAGE_ROLES.html
+ #[inline]
+ pub fn edit_role_position<R>(&self, role_id: R, position: u64) -> Result<Vec<Role>>
+ where R: Into<RoleId> {
+ self.id.edit_role_position(role_id, position)
+ }
+
/// Gets a partial amount of guild data by its Id.
///
/// Requires that the current user be in the guild.