Folder turned necessary after Discord debate

This commit is contained in:
abalabahaha
2015-11-28 21:24:49 -08:00
parent 3c0687ac95
commit 6564c27faf
25 changed files with 4281 additions and 0 deletions

101
lib/Structures/Message.js Normal file
View File

@@ -0,0 +1,101 @@
"use strict";
exports.__esModule = true;
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
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 _UtilCache = require("../Util/Cache");
var _UtilCache2 = _interopRequireDefault(_UtilCache);
var _User = require("./User");
var _User2 = _interopRequireDefault(_User);
var _UtilArgumentRegulariser = require("../Util/ArgumentRegulariser");
var _UtilEquality = require("../Util/Equality");
var _UtilEquality2 = _interopRequireDefault(_UtilEquality);
var Message = (function (_Equality) {
_inherits(Message, _Equality);
function Message(data, channel, client) {
var _this = this;
_classCallCheck(this, Message);
_Equality.call(this);
this.channel = channel;
this.client = client;
this.nonce = data.nonce;
this.attachments = data.attachments;
this.tts = data.tts;
this.embeds = data.embeds;
this.timestamp = Date.parse(data.timestamp);
this.everyoneMentioned = data.mention_everyone;
this.id = data.id;
if (data.edited_timestamp) this.editedTimestamp = Date.parse(data.edited_timestamp);
if (data.author instanceof _User2["default"]) this.author = data.author;else this.author = client.internal.users.add(new _User2["default"](data.author, client));
this.content = data.content;
this.mentions = new _UtilCache2["default"]();
data.mentions.forEach(function (mention) {
// this is .add and not .get because it allows the bot to cache
// users from messages from logs who may have left the server and were
// not previously cached.
if (mention instanceof _User2["default"]) _this.mentions.push(mention);else _this.mentions.add(client.internal.users.add(new _User2["default"](mention, client)));
});
}
Message.prototype.isMentioned = function isMentioned(user) {
user = this.client.internal.resolver.resolveUser(user);
if (user) {
return this.mentions.has("id", user.id);
} else {
return false;
}
};
Message.prototype.toString = function toString() {
return this.content;
};
Message.prototype["delete"] = function _delete() {
return this.client.deleteMessage.apply(this.client, _UtilArgumentRegulariser.reg(this, arguments));
};
Message.prototype.update = function update() {
return this.client.updateMessage.apply(this.client, _UtilArgumentRegulariser.reg(this, arguments));
};
Message.prototype.reply = function reply() {
return this.client.reply.apply(this.client, _UtilArgumentRegulariser.reg(this, arguments));
};
Message.prototype.replyTTS = function replyTTS() {
return this.client.replyTTS.apply(this.client, _UtilArgumentRegulariser.reg(this, arguments));
};
_createClass(Message, [{
key: "sender",
get: function get() {
return this.author;
}
}]);
return Message;
})(_UtilEquality2["default"]);
exports["default"] = Message;
module.exports = exports["default"];