mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-14 10:33:30 +01:00
More documentation and updated some PM Channel code
The PM Channel will now also trunc messages and cap the array size
This commit is contained in:
@@ -64,7 +64,7 @@ Gets a Message_ from the channel that matches the specified criteria. E.g:
|
|||||||
|
|
||||||
.. code-block:: js
|
.. code-block:: js
|
||||||
|
|
||||||
channel.getMessage("id", 1243987349) // returns a Channel where message.id === 1243987349
|
channel.getMessage("id", 1243987349) // returns a Message where message.id === 1243987349
|
||||||
|
|
||||||
- **key** - a `String` that is the key
|
- **key** - a `String` that is the key
|
||||||
- **value** - a `String` that is the value
|
- **value** - a `String` that is the value
|
||||||
|
|||||||
41
docs/docs_pmchannel.rst
Normal file
41
docs/docs_pmchannel.rst
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
.. include:: ./vars.rst
|
||||||
|
|
||||||
|
PMChannel Documentation
|
||||||
|
=======================
|
||||||
|
|
||||||
|
The PMChannel Class is used to represent data about a Private Message Channel.
|
||||||
|
|
||||||
|
.. note:: Beware! The PMChannel class does `not` extend the Channel_ class.
|
||||||
|
|
||||||
|
Attributes
|
||||||
|
----------
|
||||||
|
|
||||||
|
user
|
||||||
|
~~~~
|
||||||
|
|
||||||
|
The recipient User_ of the PM Channel.
|
||||||
|
|
||||||
|
id
|
||||||
|
~~
|
||||||
|
|
||||||
|
`String` UUID of the PM Channel.
|
||||||
|
|
||||||
|
messages
|
||||||
|
~~~~~~~~
|
||||||
|
|
||||||
|
An `Array` of Message_ objects. Contains all the cached messages sent in this channel up to a limit of 1000. If the limit is reached, the oldest message is removed first to make space for it.
|
||||||
|
|
||||||
|
Functions
|
||||||
|
---------
|
||||||
|
|
||||||
|
getMessage(key, value)
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
Gets a Message_ from the PM Channel that matches the specified criteria. E.g:
|
||||||
|
|
||||||
|
.. code-block:: js
|
||||||
|
|
||||||
|
pmchannel.getMessage("id", 1243987349) // returns a Message where message.id === 1243987349
|
||||||
|
|
||||||
|
- **key** - a `String` that is the key
|
||||||
|
- **value** - a `String` that is the value
|
||||||
@@ -34,6 +34,7 @@ Contents:
|
|||||||
docs_user
|
docs_user
|
||||||
docs_server
|
docs_server
|
||||||
docs_channel
|
docs_channel
|
||||||
|
docs_pmchannel
|
||||||
docs_message
|
docs_message
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
.. _Server : ./docs_server.html
|
.. _Server : ./docs_server.html
|
||||||
.. _Channel : ./docs_channel.html
|
.. _Channel : ./docs_channel.html
|
||||||
.. _Message : ./docs_message.html
|
.. _Message : ./docs_message.html
|
||||||
.. _PMChannel : #PMChannel
|
.. _PMChannel : ./docs_pmchannel.html
|
||||||
.. _Invite : #invite
|
.. _Invite : #invite
|
||||||
.. _Channel Resolvable : ./docs_resolvable.html#channel-resolvable
|
.. _Channel Resolvable : ./docs_resolvable.html#channel-resolvable
|
||||||
.. _Invite Resolvable : ./docs_resolvable.html#invite-resolvable
|
.. _Invite Resolvable : ./docs_resolvable.html#invite-resolvable
|
||||||
|
|||||||
@@ -13,6 +13,11 @@ class PMChannel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getMessage(key, value){
|
getMessage(key, value){
|
||||||
|
|
||||||
|
if(this.messages.length > 1000){
|
||||||
|
this.messages.splice(0,1);
|
||||||
|
}
|
||||||
|
|
||||||
for(var message of this.messages){
|
for(var message of this.messages){
|
||||||
if(message[key] === value){
|
if(message[key] === value){
|
||||||
return message;
|
return message;
|
||||||
|
|||||||
Reference in New Issue
Block a user