Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How can I mention a user via JDA-discord?

I want to mention the user, as I showed in this picture, I don’t understand how to do it, I had attempts I tried to do:

event.getChannel().send Message("@" + event.getMember().getNickname()).queue();

or

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

event.getChannel().send Message("@everyone").queue();

image

>Solution :

Discord mentions are done using IDs. A user mention is formatted as <@{user_id}>. In your message, this would be done this way:

event.getChannel().sendMessage("<@" + event.getMember().getId() + ">").queue()

However, you can also just use the existing method on members:

event.getChannel().sendMessage(event.getMember().getAsMention()).queue()

If you only have an id, you can also use UserSnowflake

event.getChannel().sendMessage(UserSnowflake.fromId(id).getAsMention()).queue()
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading