mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-06-03 18:42:43 +00:00
Make Message.clean_content a cached property again.
Instead, clear the cached properties so they will be re-cached when invoked again.
This commit is contained in:
parent
f235dc5ca4
commit
dfd51b95d6
@ -92,7 +92,7 @@ class Message:
|
||||
__slots__ = [ 'edited_timestamp', 'timestamp', 'tts', 'content', 'channel',
|
||||
'mention_everyone', 'embeds', 'id', 'mentions', 'author',
|
||||
'channel_mentions', 'server', '_raw_mentions', 'attachments',
|
||||
'clean_content', '_raw_channel_mentions', 'nonce' ]
|
||||
'_clean_content', '_raw_channel_mentions', 'nonce' ]
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
self._update(**kwargs)
|
||||
@ -115,7 +115,11 @@ class Message:
|
||||
self.attachments = data.get('attachments')
|
||||
self._handle_upgrades(data.get('channel_id'))
|
||||
self._handle_mentions(data.get('mentions', []))
|
||||
self.clean_content = self._clean_content()
|
||||
|
||||
# clear the cached slot cache
|
||||
del self._raw_mentions
|
||||
del self._raw_channel_mentions
|
||||
del self._clean_content
|
||||
|
||||
def _handle_mentions(self, mentions):
|
||||
self.mentions = []
|
||||
@ -156,7 +160,8 @@ class Message:
|
||||
"""
|
||||
return re.findall(r'<#([0-9]+)>', self.content)
|
||||
|
||||
def _clean_content(self):
|
||||
@utils.cached_slot_property('_clean_content')
|
||||
def clean_content(self):
|
||||
"""A property that returns the content in a "cleaned up"
|
||||
manner. This basically means that mentions are transformed
|
||||
into the way the client shows it. e.g. ``<#id>`` will transform
|
||||
|
Loading…
x
Reference in New Issue
Block a user