Skip to content

Commit

Permalink
wrap the unicode lib
Browse files Browse the repository at this point in the history
it seems to be broken, related to #42
  • Loading branch information
burdoto committed Oct 25, 2023
1 parent 10b0451 commit d49198f
Showing 1 changed file with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.comroid.api.Component;
import org.comroid.api.Polyfill;
import org.comroid.api.SupplierX;
import org.comroid.api.ThrowingSupplier;
import org.comroid.mcsd.core.entity.Server;
import org.comroid.mcsd.core.entity.User;
import org.comroid.mcsd.core.model.DiscordMessageSource;
Expand Down Expand Up @@ -92,14 +93,13 @@ public DiscordModule(Server parent) {
String str = msg.toString();
str = EmojiPattern.matcher(str).replaceAll(match -> {
var name = match.group(1);
if (EmojiUtils.isEmoji(name))
return EmojiUtils.getEmoji(name).getEmoji();
else {
var results = adapter.getJda().getEmojisByName(name, true);
return SupplierX.ofStream(results.stream())
.map(CustomEmoji::getAsMention)
.orElse("<unknown emoji>");
}
var emoji = ThrowingSupplier.fallback(()->EmojiUtils.getEmoji(name),$->null).get();
if (emoji != null)
return emoji.getEmoji();
var results = adapter.getJda().getEmojisByName(name, true);
return SupplierX.ofStream(results.stream())
.map(CustomEmoji::getAsMention)
.orElse("<unknown emoji>");
});
return new DiscordMessageSource(str)
.setDisplayUser(player.getDisplayUser(User.DisplayUser.Type.Discord, User.DisplayUser.Type.Minecraft)
Expand Down

0 comments on commit d49198f

Please sign in to comment.