Browse Source

Clear all reactions support (#136)

* Added delete channels/{channel}/messages/{message}/reactions

* Apply suggestions from code review

Co-Authored-By: LMByrne <[email protected]>

* Update client.py
pull/139/head
Luke Mathew-Byrne 6 years ago
committed by Andrei Zbikowski
parent
commit
2f44aebb6a
  1. 3
      .gitignore
  2. 3
      disco/api/client.py
  3. 1
      disco/api/http.py
  4. 9
      disco/types/message.py

3
.gitignore

@ -20,5 +20,8 @@ node_modules/
# JetBrains IDE
.idea/
# Visual Studio IDE
/.vs
# macOS
.DS_Store

3
disco/api/client.py

@ -229,6 +229,9 @@ class APIClient(LoggingClass):
self.http(route, obj)
def channels_messages_reactions_delete_all(self, channel, message):
self.http(Routes.CHANNEL_MESSAGES_REACTIONS_DELETE_ALL, dict(channel=channel, message=message))
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,

1
disco/api/http.py

@ -48,6 +48,7 @@ class Routes(object):
CHANNELS_MESSAGES_DELETE_BULK = (HTTPMethod.POST, CHANNELS + '/messages/bulk_delete')
CHANNELS_MESSAGES_REACTIONS_GET = (HTTPMethod.GET, CHANNELS + '/messages/{message}/reactions/{emoji}')
CHANNELS_MESSAGES_REACTIONS_CREATE = (HTTPMethod.PUT, CHANNELS + '/messages/{message}/reactions/{emoji}/@me')
CHANNELS_MESSAGES_REACTIONS_DELETE_ALL = (HTTPMethod.DELETE, CHANNELS + '/messages/{message}/reactions')
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}')

9
disco/types/message.py

@ -509,6 +509,15 @@ class Message(SlottedModel):
emoji,
user)
def delete_all_reactions(self):
"""
Deletes all the reactions from a message.
"""
self.client.api.channels_messages_reactions_delete_all(
self.channel_id,
self.id,
)
def is_mentioned(self, entity):
"""
Returns

Loading…
Cancel
Save