mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-11 09:03:29 +01:00
Use alternatives to .find() because that's not polyfilled
This commit is contained in:
@@ -49,9 +49,15 @@ var Message = (function (_Equality) {
|
||||
this.everyoneMentioned = data.mention_everyone || data.everyoneMentioned;
|
||||
this.id = data.id;
|
||||
|
||||
if (data.edited_timestamp) this.editedTimestamp = Date.parse(data.edited_timestamp);
|
||||
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));
|
||||
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;
|
||||
|
||||
@@ -63,15 +69,38 @@ var Message = (function (_Equality) {
|
||||
// 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.push(client.internal.users.add(new _User2["default"](mention, client)));
|
||||
if (mention instanceof _User2["default"]) {
|
||||
_this.mentions.push(mention);
|
||||
} else {
|
||||
_this.mentions.push(client.internal.users.add(new _User2["default"](mention, client)));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Message.prototype.isMentioned = function isMentioned(user) {
|
||||
user = this.client.internal.resolver.resolveUser(user);
|
||||
return !!(user && this.mentions.find(function (m) {
|
||||
return m.id == user.id;
|
||||
}));
|
||||
if (!user) {
|
||||
return false;
|
||||
}
|
||||
for (var _iterator = this.mentions, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
|
||||
var _ref;
|
||||
|
||||
if (_isArray) {
|
||||
if (_i >= _iterator.length) break;
|
||||
_ref = _iterator[_i++];
|
||||
} else {
|
||||
_i = _iterator.next();
|
||||
if (_i.done) break;
|
||||
_ref = _i.value;
|
||||
}
|
||||
|
||||
var mention = _ref;
|
||||
|
||||
if (mention.id == user.id) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
Message.prototype.toString = function toString() {
|
||||
|
||||
Reference in New Issue
Block a user