From 46807bf1c1dd5c0a12195b91b9a98b749dede3e5 Mon Sep 17 00:00:00 2001 From: abalabahaha Date: Sat, 30 Jan 2016 13:16:18 -0800 Subject: [PATCH] Fix unduplicated mentions --- lib/Structures/Message.js | 8 +++++--- src/Structures/Message.js | 8 ++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/Structures/Message.js b/lib/Structures/Message.js index a76ed019f..27015ad87 100644 --- a/lib/Structures/Message.js +++ b/lib/Structures/Message.js @@ -51,19 +51,21 @@ var Message = (function (_Equality) { var mentionData = client.internal.resolver.resolveMentions(data.content); this.cleanContent = mentionData[1]; - this.mentions = new _UtilCache2["default"](); + this.mentions = []; mentionData[0].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.add(mention);else _this.mentions.add(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.has(user)); + return !!(user && this.mentions.find(function (m) { + return m.id == user.id; + })); }; Message.prototype.toString = function toString() { diff --git a/src/Structures/Message.js b/src/Structures/Message.js index 36aedd372..026fe2f98 100644 --- a/src/Structures/Message.js +++ b/src/Structures/Message.js @@ -30,16 +30,16 @@ export default class Message extends Equality{ var mentionData = client.internal.resolver.resolveMentions(data.content); this.cleanContent = mentionData[1]; - this.mentions = new Cache(); + this.mentions = []; mentionData[0].forEach((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 User) - this.mentions.add(mention); + this.mentions.push(mention); else - this.mentions.add(client.internal.users.add(new User(mention, client))); + this.mentions.push(client.internal.users.add(new User(mention, client))); }); } @@ -49,7 +49,7 @@ export default class Message extends Equality{ isMentioned(user){ user = this.client.internal.resolver.resolveUser(user); - return !!(user && this.mentions.has(user)); + return !!(user && this.mentions.find(m => m.id == user.id)); } toString(){