Browse Source

Clean-up documentation to use NumPy style docs on remaining classes.

pull/60/head
Rapptz 9 years ago
parent
commit
9f92536441
  1. 62
      discord/message.py
  2. 2
      discord/object.py
  3. 2
      discord/user.py
  4. 11
      discord/utils.py

62
discord/message.py

@ -35,41 +35,33 @@ class Message(object):
There should be no need to create one of these manually. There should be no need to create one of these manually.
Instance attributes: Attributes
-----------
.. attribute:: edited_timestamp edited_timestamp : Optional[datetime.datetime]
A naive UTC datetime object containing the edited time of the message.
A naive UTC datetime object containing the edited time of the message. Could be None. timestamp : datetime.datetime
.. attribute:: timestamp
A naive UTC datetime object containing the time the message was created. A naive UTC datetime object containing the time the message was created.
.. attribute:: tts tts : bool
Specifies if the message was done with text-to-speech.
A boolean specifying if the message was done with text-to-speech. author
.. attribute:: author A :class:`Member` that sent the message. If :attr:`channel` is a
private channel, then it is a :class:`User` instead.
A :class:`Member` that sent the message. If :attr:`channel` is a private channel, content : str
then it is a :class:`User` instead.
.. attribute:: content
The actual contents of the message. The actual contents of the message.
.. attribute:: embeds embeds : list
A list of embedded objects. The elements are objects that meet oEmbed's specification_. A list of embedded objects. The elements are objects that meet oEmbed's specification_.
.. _specification: http://oembed.com/ .. _specification: http://oembed.com/
.. attribute:: channel channel
The :class:`Channel` that the message was sent from.
The :class:`Channel` that the message was sent from. Could be a :class:`PrivateChannel` if it's a private message. Could be a :class:`PrivateChannel` if it's a private message.
In :issue:`very rare cases <21>` this could be a :class:`Object` instead. In :issue:`very rare cases <21>` this could be a :class:`Object` instead.
For the sake of convenience, this :class:`Object` instance has an attribute ``is_private`` set to ``True``. For the sake of convenience, this :class:`Object` instance has an attribute ``is_private`` set to ``True``.
.. attribute:: server server : Optional[:class:`Server`]
The server that the message belongs to. If not applicable (i.e. a PM) then it's None instead.
The :class:`Server` that the message belongs to. If not applicable (i.e. a PM) then it's None instead. mention_everyone : bool
.. attribute:: mention_everyone Specifies if the message mentions everyone.
A boolean specifying if the message mentions everyone.
.. note:: .. note::
@ -77,8 +69,7 @@ class Message(object):
Rather this boolean indicates if the ``@everyone`` text is in the message Rather this boolean indicates if the ``@everyone`` text is in the message
**and** it did end up mentioning everyone. **and** it did end up mentioning everyone.
.. attribute:: mentions mentions : list
A list of :class:`Member` that were mentioned. If the message is in a private message A list of :class:`Member` that were mentioned. If the message is in a private message
then the list is always empty. then the list is always empty.
@ -87,15 +78,12 @@ class Message(object):
The order of the mentions list is not in any particular order so you should The order of the mentions list is not in any particular order so you should
not rely on it. This is a discord limitation, not one with the library. not rely on it. This is a discord limitation, not one with the library.
.. attribute:: channel_mentions channel_mentions : list
A list of :class:`Channel` that were mentioned. If the message is in a private message A list of :class:`Channel` that were mentioned. If the message is in a private message
then the list is always empty. then the list is always empty.
.. attribute:: id id : str
The message ID. The message ID.
.. attribute:: attachments attachments : list
A list of attachments given to a message. A list of attachments given to a message.
""" """
@ -114,7 +102,7 @@ class Message(object):
self.channel = kwargs.get('channel') self.channel = kwargs.get('channel')
self.author = User(**kwargs.get('author', {})) self.author = User(**kwargs.get('author', {}))
self.attachments = kwargs.get('attachments') self.attachments = kwargs.get('attachments')
self._handle_upgrades_and_server(kwargs.get('channel_id')) self._handle_upgrades(kwargs.get('channel_id'))
self._handle_mentions(kwargs.get('mentions', [])) self._handle_mentions(kwargs.get('mentions', []))
def _handle_mentions(self, mentions): def _handle_mentions(self, mentions):
@ -156,7 +144,7 @@ class Message(object):
""" """
return re.findall(r'<#(\d+)>', self.content) return re.findall(r'<#(\d+)>', self.content)
def _handle_upgrades_and_server(self, channel_id): def _handle_upgrades(self, channel_id):
self.server = None self.server = None
if self.channel is None: if self.channel is None:
if channel_id is not None: if channel_id is not None:

2
discord/object.py

@ -23,7 +23,7 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE. DEALINGS IN THE SOFTWARE.
""" """
class Object(object): class Object:
"""Represents a generic Discord object. """Represents a generic Discord object.
The purpose of this class is to allow you to create 'miniature' The purpose of this class is to allow you to create 'miniature'

2
discord/user.py

@ -24,7 +24,7 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE. DEALINGS IN THE SOFTWARE.
""" """
class User(object): class User:
"""Represents a Discord user. """Represents a Discord user.
Supported Operations: Supported Operations:

11
discord/utils.py

@ -58,15 +58,20 @@ def find(predicate, seq):
member = find(lambda m: m.name == 'Mighty', channel.server.members) member = find(lambda m: m.name == 'Mighty', channel.server.members)
would find the first :class:`Member` whose name is 'Mighty' and return it. would find the first :class:`Member` whose name is 'Mighty' and return it.
If an entry is not found, then ``None`` is returned.
This is different from `filter`_ due to the fact it stops the moment it finds This is different from `filter`_ due to the fact it stops the moment it finds
a valid entry. a valid entry.
.. _filter: https://docs.python.org/3.6/library/functions.html#filter .. _filter: https://docs.python.org/3.6/library/functions.html#filter
:param predicate: A function that returns a boolean-like result. Parameters
:param seq: The sequence to iterate through. -----------
:return: The first result of the predicate that returned a ``True``-like value or ``None`` if nothing was found. predicate
A function that returns a boolean-like result.
seq : iterable
The iterable to search through.
""" """
for element in seq: for element in seq:

Loading…
Cancel
Save