From 4361c1c9eaf4c31eda9410f3defd61ac34383a2b Mon Sep 17 00:00:00 2001 From: Joshument <74075169+Joshument@users.noreply.github.com> Date: Fri, 27 Oct 2023 12:58:32 -0400 Subject: [PATCH] Add `GuildId::everyone_role` and clarify how to edit default channel permissions Signed-off-by: Joshument <74075169+Joshument@users.noreply.github.com> --- src/model/channel/mod.rs | 3 +++ src/model/guild/guild_id.rs | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/src/model/channel/mod.rs b/src/model/channel/mod.rs index d174eacf4d1..c0eb5a7a7c5 100644 --- a/src/model/channel/mod.rs +++ b/src/model/channel/mod.rs @@ -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] diff --git a/src/model/guild/guild_id.rs b/src/model/guild/guild_id.rs index 24cfab16cff..11f1415edfc 100644 --- a/src/model/guild/guild_id.rs +++ b/src/model/guild/guild_id.rs @@ -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]