Skip to content

See if a message mentions @here

I want to see if a message mentions @here on Discord using the JDA library for Java.

I can already see if a message mentions @everyone using net.dv8tion.jda.api.entities.Message#mentionsEveryone() but how do I see if the message mentions @here as well?

I’ve been looking into Message#getMentions(Message.MentionType...) but I’m not sure how to use it correctly as it returns the type IMentionable.



I’ve never used this API, but the JavaDoc for IMentionable shows, that there is a method called getAsMention

@Nonnull String getAsMention()

Retrieve a Mention for this Entity. For the public Role (@everyone), 
this will return the literal string "@everyone".

So it seems all you need to do is iterate over your IMentionable instances and check if one of them is "@here"