diff --git a/docs/docs_message.rst b/docs/docs_message.rst new file mode 100644 index 000000000..553f3e088 --- /dev/null +++ b/docs/docs_message.rst @@ -0,0 +1,83 @@ +.. include:: ./vars.rst + +Message +======= + +**extends** Equality_ + +A Message object is used to represent the data of a message. + +Attributes +---------- + +channel +~~~~~~~ + +The channel the message sent in, either a TextChannel_ or PMChannel_. + +client +~~~~~~ + +The Client_ that cached the message. + +attachments +~~~~~~~~~~~ + +A raw array of attachment objects. + +tts +~~~ + +`Boolean`, true if the message was text-to-speech. + +embeds +~~~~~~ + +A raw array of embed objects. + +timestamp +~~~~~~~~~ + +`Number`, timestamp of when the message was sent. + +everyoneMentioned +~~~~~~~~~~~~~~~~~ + +`Boolean`, true if ``@everyone`` was mentioned. + +id +~~ + +`String`, ID of the message. + +editedTimestamp +~~~~~~~~~~~~~~~ + +Timestamp on when the message was last edited, `Number`. Potentially null. + +author +~~~~~~ + +The User_ that sent the message. + +content +~~~~~~~ + +`String`, content of the message. + +mentions +~~~~~~~~ + +A Cache_ of User_ objects that were mentioned in the message. + +------ + +Functions +--------- + +isMentioned(user) +~~~~~~~~~~~~~~~~~ + +Returns true if the given user was mentioned in the message. + +- **user** : A `User Resolvable`_ \ No newline at end of file diff --git a/docs/index.rst b/docs/index.rst index ca1b2c0cf..198dc4c24 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -36,6 +36,7 @@ Contents: docs_client docs_server docs_user + docs_message .. toctree:: :maxdepth: 2 diff --git a/docs/vars.rst b/docs/vars.rst index d611640de..153134e31 100644 --- a/docs/vars.rst +++ b/docs/vars.rst @@ -5,5 +5,8 @@ .. _Channel : ./docs_channel.html .. _ServerChannel : ./docs_serverchannel.html .. _TextChannel : ./docs_textchannel.html +.. _VoiceChannel : ./docs_voicechannel.html +.. _PMChannel : ./docs_pmchannel.html +.. _Message : ./docs_message.html .. _Promises : https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Promise .. _EventEmitter : https://nodejs.org/api/events.html#events_class_events_eventemitter \ No newline at end of file diff --git a/lib/Structures/Message.js b/lib/Structures/Message.js index 55a76fdb1..1ce11716d 100644 --- a/lib/Structures/Message.js +++ b/lib/Structures/Message.js @@ -2,16 +2,22 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + var Cache = require("../Util/Cache.js"); var User = require("./User.js"); var reg = require("../Util/ArgumentRegulariser.js").reg; +var Equality = require("../Util/Equality"); + +var Message = (function (_Equality) { + _inherits(Message, _Equality); -var Message = (function () { function Message(data, channel, client) { var _this = this; _classCallCheck(this, Message); + _Equality.call(this); this.channel = channel; this.client = client; this.nonce = data.nonce; @@ -67,6 +73,6 @@ var Message = (function () { }; return Message; -})(); +})(Equality); module.exports = Message; \ No newline at end of file diff --git a/src/Structures/Message.js b/src/Structures/Message.js index b73e7d82c..3df128e95 100644 --- a/src/Structures/Message.js +++ b/src/Structures/Message.js @@ -3,9 +3,11 @@ var Cache = require("../Util/Cache.js"); var User = require("./User.js"); var reg = require("../Util/ArgumentRegulariser.js").reg; +var Equality = require("../Util/Equality"); -class Message{ - constructor(data, channel, client){ +class Message extends Equality{ + constructor(data, channel, client) { + super(); this.channel = channel; this.client = client; this.nonce = data.nonce;