Browse Source

Add MessageReactionRemoveEmoji event and endpoint (#172)

pull/173/head
PixeL 5 years ago
committed by Andrei Zbikowski
parent
commit
cea1dffb17
  1. 3
      disco/api/client.py
  2. 2
      disco/api/http.py
  3. 28
      disco/gateway/events.py
  4. 16
      disco/types/message.py

3
disco/api/client.py

@ -230,6 +230,9 @@ class APIClient(LoggingClass):
self.http(route, obj)
def channels_messages_reactions_delete_emoji(self, channel, message, emoji):
self.http(Routes.CHANNELS_MESSAGES_REACTIONS_DELETE_EMOJI, dict(channel=channel, message=message, emoji=emoji))
def channels_permissions_modify(self, channel, permission, allow, deny, typ, reason=None):
self.http(Routes.CHANNELS_PERMISSIONS_MODIFY, dict(channel=channel, permission=permission), json={
'allow': allow,

2
disco/api/http.py

@ -54,6 +54,8 @@ class Routes(object):
CHANNELS_MESSAGES_REACTIONS_DELETE_ME = (HTTPMethod.DELETE, CHANNELS + '/messages/{message}/reactions/{emoji}/@me')
CHANNELS_MESSAGES_REACTIONS_DELETE_USER = (HTTPMethod.DELETE,
CHANNELS + '/messages/{message}/reactions/{emoji}/{user}')
CHANNELS_MESSAGES_REACTIONS_DELETE_EMOJI = (HTTPMethod.DELETE,
CHANNELS + '/messages/{message}/reactions/{emoji}')
CHANNELS_PERMISSIONS_MODIFY = (HTTPMethod.PUT, CHANNELS + '/permissions/{permission}')
CHANNELS_PERMISSIONS_DELETE = (HTTPMethod.DELETE, CHANNELS + '/permissions/{permission}')
CHANNELS_INVITES_LIST = (HTTPMethod.GET, CHANNELS + '/invites')

28
disco/gateway/events.py

@ -716,3 +716,31 @@ class MessageReactionRemoveAll(GatewayEvent):
@property
def guild(self):
return self.channel.guild
class MessageReactionRemoveEmoji(GatewayEvent):
"""
Sent when all reactions of a single emoji are removed from a message.
Attributes
----------
guild_id : Snowflake
The guild ID the message is in.
channel_id : Snowflake
The channel ID the message is in.
message_id : Snowflake
The ID of the message for which the reaction was removed from.
emoji : :class:`disco.types.message.MessageReactionEmoji`
The emoji that was removed.
"""
guild_id = Field(snowflake)
channel_id = Field(snowflake)
message_id = Field(snowflake)
emoji = Field(MessageReactionEmoji)
@property
def channel(self):
return self.client.state.channels.get(self.channel_id)
@property
def guild(self):
return self.channel.guild

16
disco/types/message.py

@ -512,6 +512,22 @@ class Message(SlottedModel):
emoji,
user)
def delete_single_reaction(self, emoji):
"""
Deletes all reactions of a single emoji from a message.
Parameters
----------
emoji : `Emoji`|str
An emoji or string representing an emoji
"""
if isinstance(emoji, Emoji):
emoji = emoji.to_string()
self.client.api.channels_messages_reactions_delete_emoji(
self.channel_id,
self.id,
emoji)
def is_mentioned(self, entity):
"""
Returns

Loading…
Cancel
Save