diff options
| author | Austin Hellyer <[email protected]> | 2016-11-05 14:44:11 -0700 |
|---|---|---|
| committer | Austin Hellyer <[email protected]> | 2016-11-05 14:44:11 -0700 |
| commit | e3416d3f511894553b7625c501043077977ccb4d (patch) | |
| tree | c2f9f5d35a90c649dcc67c6d15e4a9ae8478cdeb /src/model/permissions.rs | |
| parent | Update URLs to GitLab (diff) | |
| download | serenity-e3416d3f511894553b7625c501043077977ccb4d.tar.xz serenity-e3416d3f511894553b7625c501043077977ccb4d.zip | |
Add message reactions
Add message reaction structs and an enum to differentiate between the
two types of reactions, as well as event decoding and event handlers
with dispatches.
The following is, more or less, what is added:
- `reactions` field to the `Message` struct;
- `MessageReaction` struct, which is a consolidated form of reaction,
containing the type of reaction, the number of them, and whether the
current user has performed that type of reaction;
- `Reaction`, a struct containing the information about a reaction
- `ReactionType`, an enum to differentiate between the two types of
reactions: `Custom` (a guild's custom emoji) and `Unicode` (twemoji);
- Decoding for `MESSAGE_REACTION_ADD` and `MESSAGE_REACTION_REMOVE`;
- Permission flag `ADD_REACTIONS`;
- `Message::react` method;
- Three `http` payload senders: `create_reaction`, `delete_reaction`,
and `get_reaction_users`;
- Three `Context` methods of equal names to the above.
Diffstat (limited to 'src/model/permissions.rs')
| -rw-r--r-- | src/model/permissions.rs | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/src/model/permissions.rs b/src/model/permissions.rs index 7eccc5c..3bcf219 100644 --- a/src/model/permissions.rs +++ b/src/model/permissions.rs @@ -42,6 +42,7 @@ use ::prelude::*; /// /// This includes the following permissions: /// +/// - [Add Reactions] /// - [Attach Files] /// - [Change Nickname] /// - [Connect] @@ -65,6 +66,7 @@ use ::prelude::*; /// permissions::general().toggle(permissions::SEND_TTS_MESSAGES); /// ``` /// +/// [Add Reactions]: constant.ADD_REACTIONS.html /// [Attach Files]: constant.ATTACH_FILES.html /// [Change Nickname]: constant.CHANGE_NICKNAME.html /// [Connect]: constant.CONNECT.html @@ -81,9 +83,9 @@ use ::prelude::*; pub fn general() -> Permissions { use self::*; - ATTACH_FILES | CHANGE_NICKNAME | CONNECT | CREATE_INVITE | EMBED_LINKS | - MENTION_EVERYONE | READ_MESSAGE_HISTORY | READ_MESSAGES | SEND_MESSAGES | - SEND_TTS_MESSAGES | SPEAK | USE_VAD | USE_EXTERNAL_EMOJIS + ADD_REACTIONS | ATTACH_FILES | CHANGE_NICKNAME | CONNECT | CREATE_INVITE | + EMBED_LINKS | MENTION_EVERYONE | READ_MESSAGE_HISTORY | READ_MESSAGES | + SEND_MESSAGES | SEND_TTS_MESSAGES | SPEAK | USE_VAD | USE_EXTERNAL_EMOJIS } /// Returns a set of text-only permissions with the original `@everyone` @@ -91,6 +93,7 @@ pub fn general() -> Permissions { /// /// This includes the text permissions given via [`general`]: /// +/// - [Add Reactions] /// - [Attach Files] /// - [Change Nickname] /// - [Create Invite] @@ -103,6 +106,7 @@ pub fn general() -> Permissions { /// - [Use External Emojis] /// /// [`general`]: fn.general.html +/// [Add Reactions]: constant.ADD_REACTIONS.html /// [Attach Files]: constant.ATTACH_FILES.html /// [Change Nickname]: constant.CHANGE_NICKNAME.html /// [Create Invite]: constant.CREATE_INVITE.html @@ -116,9 +120,9 @@ pub fn general() -> Permissions { pub fn text() -> Permissions { use self::*; - ATTACH_FILES | CHANGE_NICKNAME | CREATE_INVITE | EMBED_LINKS | - MENTION_EVERYONE | READ_MESSAGE_HISTORY | READ_MESSAGES | SEND_MESSAGES | - SEND_TTS_MESSAGES | USE_EXTERNAL_EMOJIS + ADD_REACTIONS | ATTACH_FILES | CHANGE_NICKNAME | CREATE_INVITE | + EMBED_LINKS | MENTION_EVERYONE | READ_MESSAGE_HISTORY | READ_MESSAGES | + SEND_MESSAGES | SEND_TTS_MESSAGES | USE_EXTERNAL_EMOJIS } /// Returns a set of voice-only permissions with the original `@everyone` @@ -166,6 +170,14 @@ bitflags! { /// /// [guild]: ../struct.LiveGuild.html const MANAGE_GUILD = 1 << 5, + /// [`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. + /// + /// [`Member`]: ../struct.Member.html + /// [`Message`]: ../struct.Message.html + /// [`Reaction`]: ../struct.Reaction.html + const ADD_REACTIONS = 1 << 6, /// 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 = 1 << 10, |