mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
Added message deletion
This commit is contained in:
@@ -1,41 +1,76 @@
|
||||
"use strict";
|
||||
|
||||
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 _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||
|
||||
var User = require("./user.js").User;
|
||||
var List = require("./list.js").List;
|
||||
var PMChannel = require("./PMChannel.js").PMChannel;
|
||||
|
||||
exports.Message = function (time, author, content, channel, id, mentions, everyoneMentioned, embeds) {
|
||||
var Message = (function () {
|
||||
function Message(data, channel, mentions, author) {
|
||||
_classCallCheck(this, Message);
|
||||
|
||||
if (!content) {
|
||||
message = time;
|
||||
channel = author;
|
||||
time = message.timestamp;
|
||||
author = message.author;
|
||||
content = message.content;
|
||||
id = message.id;
|
||||
mentions = message.mentions;
|
||||
everyoneMentioned = message.mention_everyone;
|
||||
embeds = message.embeds;
|
||||
this.tts = data.tts;
|
||||
this.timestamp = Date.parse(data.timestamp);
|
||||
this.nonce = data.nonce;
|
||||
this.mentions = mentions;
|
||||
this.everyoneMentioned = data.mention_everyone;
|
||||
this.id = data.id;
|
||||
this.embeds = data.embeds;
|
||||
this.editedTimestamp = data.edited_timestamp;
|
||||
this.content = data.content.trim();
|
||||
this.channel = channel;
|
||||
this.author = author;
|
||||
this.attachments = data.attachments;
|
||||
}
|
||||
|
||||
this.time = Date.parse(time);
|
||||
this.author = new User(author);
|
||||
this.content = content.replace(/\s+/g, ' ').trim(); //content.replace(/<[^>]*>/g, "").replace(/\s+/g, ' ').trim();
|
||||
this.channel = channel;
|
||||
this.id = id;
|
||||
this.mentions = new List("id");
|
||||
this.everyoneMentioned = everyoneMentioned;
|
||||
this.embeds = embeds;
|
||||
for (x in mentions) {
|
||||
var _mention = mentions[x];
|
||||
this.mentions.add(new User(_mention));
|
||||
}
|
||||
};
|
||||
/*exports.Message.prototype.isPM = function() {
|
||||
return ( this.channel instanceof PMChannel );
|
||||
}*/
|
||||
|
||||
exports.Message.prototype.isPM = function () {
|
||||
return this.channel instanceof PMChannel;
|
||||
};
|
||||
_createClass(Message, [{
|
||||
key: "isMentioned",
|
||||
value: function isMentioned(user) {
|
||||
var id = user.id ? user.id : user;
|
||||
var _iteratorNormalCompletion = true;
|
||||
var _didIteratorError = false;
|
||||
var _iteratorError = undefined;
|
||||
|
||||
exports.Message.prototype.isMentioned = function (user) {
|
||||
return this.mentions.filter("id", user.id).length > 0;
|
||||
};
|
||||
try {
|
||||
for (var _iterator = this.mentions[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
||||
var mention = _step.value;
|
||||
|
||||
if (mention.id === id) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
_didIteratorError = true;
|
||||
_iteratorError = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_iteratorNormalCompletion && _iterator["return"]) {
|
||||
_iterator["return"]();
|
||||
}
|
||||
} finally {
|
||||
if (_didIteratorError) {
|
||||
throw _iteratorError;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}, {
|
||||
key: "sender",
|
||||
get: function get() {
|
||||
return this.author;
|
||||
}
|
||||
}]);
|
||||
|
||||
return Message;
|
||||
})();
|
||||
|
||||
module.exports = Message;
|
||||
Reference in New Issue
Block a user