I am trying to code a command to DM a mention person,dm @JohnDoe, However, the mentioned user is a "Member". and DMing requires a "User".
Member mentioned = event.getMessage().getMentionedMembers().get(0);
mentioned.openPrivateChannel().queue(DM -> { //Program Expected User not Member while "mentioned" is a Member.
DM.sendMessage("You've been DMed.").queue(); };
Note: This isn't a duplicate of JDA - Converting "User" to "Member" , I am converting from Member to User, not User to member.
I am trying to know how to convert from Member to User and not vice versa. Also, If there's another way than converting please let me know. Thanks, Bedo
I believe it is:
User user = mentioned.getUser();
As described here: https://ci.dv8tion.net/job/JDA/javadoc/net/dv8tion/jda/api/entities/Member.html
getUser() : "The user wrapped by this Entity."
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.