@@ -173,28 +173,35 @@ class MessageMentions {
173
173
* @typedef {Object } MessageMentionsHasOptions
174
174
* @property {boolean } [ignoreDirect=false] Whether to ignore direct mentions to the item
175
175
* @property {boolean } [ignoreRoles=false] Whether to ignore role mentions to a guild member
176
- * @property {boolean } [ignoreEveryone=false] Whether to ignore everyone/here mentions
176
+ * @property {boolean } [ignoreRepliedUser=false] Whether to ignore replied user mention to an user
177
+ * @property {boolean } [ignoreEveryone=false] Whether to ignore `@everyone`/`@here` mentions
177
178
*/
178
179
179
180
/**
180
- * Checks if a user, guild member, role, or channel is mentioned.
181
- * Takes into account user mentions, role mentions, and `@everyone`/`@here` mentions.
181
+ * Checks if a user, guild member, thread member, role, or channel is mentioned.
182
+ * Takes into account user mentions, role mentions, channel mentions,
183
+ * replied user mention, and `@everyone`/`@here` mentions.
182
184
* @param {UserResolvable|RoleResolvable|ChannelResolvable } data The User/Role/Channel to check for
183
185
* @param {MessageMentionsHasOptions } [options] The options for the check
184
186
* @returns {boolean }
185
187
*/
186
- has ( data , { ignoreDirect = false , ignoreRoles = false , ignoreEveryone = false } = { } ) {
187
- if ( ! ignoreEveryone && this . everyone ) return true ;
188
- const { GuildMember } = require ( './GuildMember' ) ;
189
- if ( ! ignoreRoles && data instanceof GuildMember ) {
190
- for ( const role of this . roles . values ( ) ) if ( data . roles . cache . has ( role . id ) ) return true ;
191
- }
188
+ has ( data , { ignoreDirect = false , ignoreRoles = false , ignoreRepliedUser = false , ignoreEveryone = false } = { } ) {
189
+ const user = this . client . users . resolve ( data ) ;
190
+ const role = this . guild ?. roles . resolve ( data ) ;
191
+ const channel = this . client . channels . resolve ( data ) ;
192
192
193
+ if ( ! ignoreRepliedUser && this . users . has ( this . repliedUser ?. id ) && this . repliedUser ?. id === user ?. id ) return true ;
193
194
if ( ! ignoreDirect ) {
194
- const id =
195
- this . guild ?. roles . resolveId ( data ) ?? this . client . channels . resolveId ( data ) ?? this . client . users . resolveId ( data ) ;
196
-
197
- return typeof id === 'string' && ( this . users . has ( id ) || this . channels . has ( id ) || this . roles . has ( id ) ) ;
195
+ if ( this . users . has ( user ?. id ) ) return true ;
196
+ if ( this . roles . has ( role ?. id ) ) return true ;
197
+ if ( this . channels . has ( channel ?. id ) ) return true ;
198
+ }
199
+ if ( user && ! ignoreEveryone && this . everyone ) return true ;
200
+ if ( ! ignoreRoles ) {
201
+ const member = this . guild ?. members . resolve ( data ) ;
202
+ if ( member ) {
203
+ for ( const mentionedRole of this . roles . values ( ) ) if ( member . roles . cache . has ( mentionedRole . id ) ) return true ;
204
+ }
198
205
}
199
206
200
207
return false ;
0 commit comments