aboutsummaryrefslogtreecommitdiff
path: root/src/model/permissions.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/model/permissions.rs')
-rw-r--r--src/model/permissions.rs84
1 files changed, 45 insertions, 39 deletions
diff --git a/src/model/permissions.rs b/src/model/permissions.rs
index dbf0b69..0076b05 100644
--- a/src/model/permissions.rs
+++ b/src/model/permissions.rs
@@ -145,41 +145,47 @@ pub const PRESET_VOICE: Permissions = Permissions {
bits: 0b0000_0011_1111_0000_0000_0000_0000_0000,
};
-bitflags! {
- /// A set of permissions that can be assigned to [`User`]s and [`Role`]s via
- /// [`PermissionOverwrite`]s, roles globally in a [`Guild`], and to
- /// [`GuildChannel`]s.
- ///
- /// [`Guild`]: ../struct.Guild.html
- /// [`GuildChannel`]: ../struct.GuildChannel.html
- /// [`PermissionOverwrite`]: ../struct.PermissionOverwrite.html
- /// [`Role`]: ../struct.Role.html
- /// [`User`]: ../struct.User.html
- pub struct Permissions: u64 {
+/// A set of permissions that can be assigned to [`User`]s and [`Role`]s via
+/// [`PermissionOverwrite`]s, roles globally in a [`Guild`], and to
+/// [`GuildChannel`]s.
+///
+/// [`Guild`]: ../struct.Guild.html
+/// [`GuildChannel`]: ../struct.GuildChannel.html
+/// [`PermissionOverwrite`]: ../struct.PermissionOverwrite.html
+/// [`Role`]: ../struct.Role.html
+/// [`User`]: ../struct.User.html
+///
+#[derive(Copy, PartialEq, Eq, Clone, PartialOrd, Ord, Hash)]
+pub struct Permissions {
+ bits: u64
+}
+
+__impl_bitflags! {
+ Permissions: u64 {
/// Allows for the creation of [`RichInvite`]s.
///
/// [`RichInvite`]: ../struct.RichInvite.html
- const CREATE_INVITE = 0b0000_0000_0000_0000_0000_0000_0000_0001;
+ CREATE_INVITE = 0b0000_0000_0000_0000_0000_0000_0000_0001;
/// Allows for the kicking of guild [member]s.
///
/// [member]: ../struct.Member.html
- const KICK_MEMBERS = 0b0000_0000_0000_0000_0000_0000_0000_0010;
+ KICK_MEMBERS = 0b0000_0000_0000_0000_0000_0000_0000_0010;
/// Allows the banning of guild [member]s.
///
/// [member]: ../struct.Member.html
- const BAN_MEMBERS = 0b0000_0000_0000_0000_0000_0000_0000_0100;
+ BAN_MEMBERS = 0b0000_0000_0000_0000_0000_0000_0000_0100;
/// Allows all permissions, bypassing channel [permission overwrite]s.
///
/// [permission overwrite]: ../struct.PermissionOverwrite.html
- const ADMINISTRATOR = 0b0000_0000_0000_0000_0000_0000_0000_1000;
+ ADMINISTRATOR = 0b0000_0000_0000_0000_0000_0000_0000_1000;
/// Allows management and editing of guild [channel]s.
///
/// [channel]: ../struct.GuildChannel.html
- const MANAGE_CHANNELS = 0b0000_0000_0000_0000_0000_0000_0001_0000;
+ MANAGE_CHANNELS = 0b0000_0000_0000_0000_0000_0000_0001_0000;
/// Allows management and editing of the [guild].
///
/// [guild]: ../struct.Guild.html
- const MANAGE_GUILD = 0b0000_0000_0000_0000_0000_0000_0010_0000;
+ MANAGE_GUILD = 0b0000_0000_0000_0000_0000_0000_0010_0000;
/// [`Member`]s with this permission can add new [`Reaction`]s to a
/// [`Message`]. Members can still react using reactions already added
/// to messages without this permission.
@@ -187,70 +193,70 @@ bitflags! {
/// [`Member`]: ../struct.Member.html
/// [`Message`]: ../struct.Message.html
/// [`Reaction`]: ../struct.Reaction.html
- const ADD_REACTIONS = 0b0000_0000_0000_0000_0000_0000_0100_0000;
+ ADD_REACTIONS = 0b0000_0000_0000_0000_0000_0000_0100_0000;
// Allows viewing a guild's audit logs.
- const VIEW_AUDIT_LOG = 0b0000_0000_0000_0000_0000_0000_1000_0000;
+ VIEW_AUDIT_LOG = 0b0000_0000_0000_0000_0000_0000_1000_0000;
/// Allows reading messages in a guild channel. If a user does not have
/// this permission, then they will not be able to see the channel.
- const READ_MESSAGES = 0b0000_0000_0000_0000_0000_0100_0000_0000;
+ READ_MESSAGES = 0b0000_0000_0000_0000_0000_0100_0000_0000;
/// Allows sending messages in a guild channel.
- const SEND_MESSAGES = 0b0000_0000_0000_0000_0000_1000_0000_0000;
+ SEND_MESSAGES = 0b0000_0000_0000_0000_0000_1000_0000_0000;
/// Allows the sending of text-to-speech messages in a channel.
- const SEND_TTS_MESSAGES = 0b0000_0000_0000_0000_0001_0000_0000_0000;
+ SEND_TTS_MESSAGES = 0b0000_0000_0000_0000_0001_0000_0000_0000;
/// Allows the deleting of other messages in a guild channel.
///
/// **Note**: This does not allow the editing of other messages.
- const MANAGE_MESSAGES = 0b0000_0000_0000_0000_0010_0000_0000_0000;
+ MANAGE_MESSAGES = 0b0000_0000_0000_0000_0010_0000_0000_0000;
/// Allows links from this user - or users of this role - to be
/// embedded, with potential data such as a thumbnail, description, and
/// page name.
- const EMBED_LINKS = 0b0000_0000_0000_0000_0100_0000_0000_0000;
+ EMBED_LINKS = 0b0000_0000_0000_0000_0100_0000_0000_0000;
/// Allows uploading of files.
- const ATTACH_FILES = 0b0000_0000_0000_0000_1000_0000_0000_0000;
+ ATTACH_FILES = 0b0000_0000_0000_0000_1000_0000_0000_0000;
/// Allows the reading of a channel's message history.
- const READ_MESSAGE_HISTORY = 0b0000_0000_0000_0001_0000_0000_0000_0000;
+ READ_MESSAGE_HISTORY = 0b0000_0000_0000_0001_0000_0000_0000_0000;
/// Allows the usage of the `@everyone` mention, which will notify all
/// users in a channel. The `@here` mention will also be available, and
/// can be used to mention all non-offline users.
///
/// **Note**: You probably want this to be disabled for most roles and
/// users.
- const MENTION_EVERYONE = 0b0000_0000_0000_0010_0000_0000_0000_0000;
+ MENTION_EVERYONE = 0b0000_0000_0000_0010_0000_0000_0000_0000;
/// Allows the usage of custom emojis from other guilds.
///
/// This does not dictate whether custom emojis in this guild can be
/// used in other guilds.
- const USE_EXTERNAL_EMOJIS = 0b0000_0000_0000_0100_0000_0000_0000_0000;
+ USE_EXTERNAL_EMOJIS = 0b0000_0000_0000_0100_0000_0000_0000_0000;
/// Allows the joining of a voice channel.
- const CONNECT = 0b0000_0000_0001_0000_0000_0000_0000_0000;
+ CONNECT = 0b0000_0000_0001_0000_0000_0000_0000_0000;
/// Allows the user to speak in a voice channel.
- const SPEAK = 0b0000_0000_0010_0000_0000_0000_0000_0000;
+ SPEAK = 0b0000_0000_0010_0000_0000_0000_0000_0000;
/// Allows the muting of members in a voice channel.
- const MUTE_MEMBERS = 0b0000_0000_0100_0000_0000_0000_0000_0000;
+ MUTE_MEMBERS = 0b0000_0000_0100_0000_0000_0000_0000_0000;
/// Allows the deafening of members in a voice channel.
- const DEAFEN_MEMBERS = 0b0000_0000_1000_0000_0000_0000_0000_0000;
+ DEAFEN_MEMBERS = 0b0000_0000_1000_0000_0000_0000_0000_0000;
/// Allows the moving of members from one voice channel to another.
- const MOVE_MEMBERS = 0b0000_0001_0000_0000_0000_0000_0000_0000;
+ MOVE_MEMBERS = 0b0000_0001_0000_0000_0000_0000_0000_0000;
/// Allows the usage of voice-activity-detection in a [voice] channel.
///
/// If this is disabled, then [`Member`]s must use push-to-talk.
///
/// [`Member`]: ../struct.Member.html
/// [voice]: ../enum.ChannelType.html#variant.Voice
- const USE_VAD = 0b0000_0010_0000_0000_0000_0000_0000_0000;
+ USE_VAD = 0b0000_0010_0000_0000_0000_0000_0000_0000;
/// Allows members to change their own nickname in the guild.
- const CHANGE_NICKNAME = 0b0000_0100_0000_0000_0000_0000_0000_0000;
+ CHANGE_NICKNAME = 0b0000_0100_0000_0000_0000_0000_0000_0000;
/// Allows members to change other members' nicknames.
- const MANAGE_NICKNAMES = 0b0000_1000_0000_0000_0000_0000_0000_0000;
+ MANAGE_NICKNAMES = 0b0000_1000_0000_0000_0000_0000_0000_0000;
/// Allows management and editing of roles below their own.
- const MANAGE_ROLES = 0b0001_0000_0000_0000_0000_0000_0000_0000;
+ MANAGE_ROLES = 0b0001_0000_0000_0000_0000_0000_0000_0000;
/// Allows management of webhooks.
- const MANAGE_WEBHOOKS = 0b0010_0000_0000_0000_0000_0000_0000_0000;
+ MANAGE_WEBHOOKS = 0b0010_0000_0000_0000_0000_0000_0000_0000;
/// Allows management of emojis created without the use of an
/// [`Integration`].
///
/// [`Integration`]: ../struct.Integration.html
- const MANAGE_EMOJIS = 0b0100_0000_0000_0000_0000_0000_0000_0000;
+ MANAGE_EMOJIS = 0b0100_0000_0000_0000_0000_0000_0000_0000;
}
}