fix merge conflict

This commit is contained in:
iDutchy
2020-11-24 17:19:31 -06:00
22 changed files with 448 additions and 64 deletions

View File

@@ -43,6 +43,7 @@ from .file import File
from .utils import escape_mentions
from .guild import Guild
from .mixins import Hashable
from .sticker import Sticker
class Attachment:
@@ -286,11 +287,15 @@ class MessageReference:
def flatten_handlers(cls):
prefix = len('_handle_')
cls._HANDLERS = {
key[prefix:]: value
handlers = [
(key[prefix:], value)
for key, value in cls.__dict__.items()
if key.startswith('_handle_')
}
if key.startswith('_handle_') and key != '_handle_member'
]
# store _handle_member last
handlers.append(('member', cls._handle_member))
cls._HANDLERS = handlers
cls._CACHED_SLOTS = [
attr for attr in cls.__slots__ if attr.startswith('_cs_')
]
@@ -392,6 +397,10 @@ class Message(Hashable):
- ``description``: A string representing the application's description.
- ``icon``: A string representing the icon ID of the application.
- ``cover_image``: A string representing the embed's image asset ID.
stickers: List[:class:`Sticker`]
A list of stickers given to the message.
.. versionadded:: 1.6
"""
__slots__ = ('_edited_timestamp', 'tts', 'content', 'channel', 'webhook_id',
@@ -399,8 +408,8 @@ class Message(Hashable):
'_cs_channel_mentions', '_cs_raw_mentions', 'attachments',
'_cs_clean_content', '_cs_raw_channel_mentions', 'nonce', 'pinned',
'role_mentions', '_cs_raw_role_mentions', 'type', 'call', 'flags',
'_cs_system_content', '_cs_guild', '_state', 'reactions', 'reference',
'application', 'activity')
'_cs_system_content', '_cs_guild', '_state', 'reactions', 'reference',
'application', 'activity', 'stickers')
def __init__(self, *, state, channel, data):
self._state = state
@@ -420,6 +429,7 @@ class Message(Hashable):
self.tts = data['tts']
self.content = data['content']
self.nonce = data.get('nonce')
self.stickers = [Sticker(data=data, state=state) for data in data.get('stickers', [])]
ref = data.get('message_reference')
self.reference = MessageReference(state, **ref) if ref is not None else None
@@ -496,10 +506,13 @@ class Message(Hashable):
return reaction
def _update(self, data):
handlers = self._HANDLERS
for key, value in data.items():
# In an update scheme, 'author' key has to be handled before 'member'
# otherwise they overwrite each other which is undesirable.
# Since there's no good way to do this we have to iterate over every
# handler rather than iterating over the keys which is a little slower
for key, handler in self._HANDLERS:
try:
handler = handlers[key]
value = data[key]
except KeyError:
continue
else: