Skip to content

Commit

Permalink
Add GuildId::everyone_role and clarify how to edit default channel …
Browse files Browse the repository at this point in the history
…permissions

Signed-off-by: Joshument <[email protected]>
  • Loading branch information
Joshument authored and arqunis committed Nov 2, 2023
1 parent 794d458 commit 4361c1c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/model/channel/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,9 @@ pub struct PermissionOverwrite {
///
/// This is for use with methods such as [`GuildChannel::create_permission`].
///
/// If you would like to modify the default permissions of a channel, you can get its [`RoleId`]
/// from [`GuildId::everyone_role`].
///
/// [Discord docs](https://discord.com/developers/docs/resources/channel#overwrite-object-overwrite-structure) (field `type`).
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
#[non_exhaustive]
Expand Down
7 changes: 7 additions & 0 deletions src/model/guild/guild_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -868,6 +868,13 @@ impl GuildId {
Ok(roles.into_iter().map(|r| (r.id, r)).collect())
}

/// Gets the default permission role (@everyone) from the guild.
#[inline]
#[must_use]
pub fn everyone_role(&self) -> RoleId {
RoleId::from(self.get())
}

/// Tries to find the [`Guild`] by its Id in the cache.
#[cfg(feature = "cache")]
#[inline]
Expand Down

0 comments on commit 4361c1c

Please sign in to comment.