add MessageMentions#has, remove old method (#1724)

* Update MessageMentions.js

* remove old method

* smh

* Update Message.js

* Update MessageMentions.js

* Update MessageMentions.js

* Update MessageMentions.js
This commit is contained in:
Gus Caplan
2017-07-31 21:49:00 -05:00
committed by Crawl
parent 5799ba28f9
commit 963cf42e0d
2 changed files with 17 additions and 26 deletions

View File

@@ -1,4 +1,5 @@
const Collection = require('../util/Collection');
const GuildMember = require('./GuildMember');
/**
* Keeps track of mentions in a {@link Message}.
@@ -115,6 +116,22 @@ class MessageMentions {
}
return this._channels;
}
/**
* Check if a user is mentioned. Takes into account user mentions, role
* mentions, and @everyone/@here mentions.
* @param {UserResolvable|GuildMember|Role|GuildChannel} data User/GuildMember/Role/Channel to check
* @param {boolean} [strict=true] If role mentions and everyone/here mentions should be included
* @returns {boolean}
*/
has(data, strict = true) {
if (strict && this.everyone) return true;
if (strict && data instanceof GuildMember) {
for (const role of this.roles) if (data.roles.has(role.id)) return true;
}
const id = data.id || data;
return this.users.has(id) || this.channels.has(id) || this.roles.has(id);
}
}
/**