mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-10 16:43:31 +01:00
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:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user