use of gg.projecteden.nexus.models.discord.DiscordUserService in project Nexus by ProjectEdenGG.
the class IngameBridgeListener method parseMentions.
public static String parseMentions(String message) {
if (message != null && message.contains("@")) {
Matcher matcher = Pattern.compile("@[\\w]+").matcher(message);
while (matcher.find()) {
String group = matcher.group();
String search = group.replace("@", "");
Nerd nerd = new NerdService().findExact(search);
if (nerd != null) {
DiscordUser mentioned = new DiscordUserService().get(nerd);
if (mentioned.getUserId() != null) {
message = message.replace(group, "<@" + mentioned.getUserId() + ">");
} else {
Nickname fromNickname = new NicknameService().getFromNickname(search);
if (fromNickname != null) {
mentioned = new DiscordUserService().get(fromNickname);
if (mentioned.getUserId() != null)
message = message.replace(group, "<@" + mentioned.getUserId() + ">");
}
}
}
}
}
return message;
}
Aggregations