Skip to content

Commit b9f2df3

Browse files
committed
Use emoji names instead of IDs
1 parent f3ca0d4 commit b9f2df3

File tree

2 files changed

+21
-18
lines changed

2 files changed

+21
-18
lines changed

src/main/java/org/geysermc/discordbot/listeners/PreviewHandler.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,13 @@ public void onMessageReceived(@Nonnull MessageReceivedEvent event) {
8484
return;
8585
}
8686

87+
String title = pullRequest.getTitle();
88+
if (title.length() > 100) {
89+
title = title.substring(0, 97) + "...";
90+
}
91+
8792
previewChannel.createForumPost(
88-
pullRequest.getTitle(),
93+
title,
8994
MessageCreateData.fromEmbeds(new EmbedBuilder()
9095
.setTitle(pullRequest.getTitle())
9196
.setColor(BotColors.SUCCESS.getColor())

src/main/java/org/geysermc/discordbot/util/BotEmojis.java

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -30,29 +30,27 @@
3030
import net.dv8tion.jda.api.entities.emoji.Emoji;
3131

3232
import java.util.EnumMap;
33+
import java.util.Locale;
34+
import java.util.stream.Collectors;
3335

3436
public enum BotEmojis {
35-
// Platforms // TODO add the real emoji IDs
36-
FABRIC("1475218517400879346"),
37-
GEYSER("1475218518432809010"),
38-
NEOFORGE("1475218519720198317"),
39-
PAPER("1475218520945070202"),
40-
VELOCITY("1475218521884459182"),
41-
VIAPROXY("1475218523042353417"),
42-
WATERFALL("1475218524116090970");
37+
// Platforms
38+
FABRIC,
39+
GEYSER,
40+
NEOFORGE,
41+
PAPER,
42+
VELOCITY,
43+
VIAPROXY,
44+
WATERFALL;
4345

4446
private static final EnumMap<BotEmojis, ApplicationEmoji> EMOJI_MAP = new EnumMap<>(BotEmojis.class);
4547

4648
public static void init(JDA jda) {
47-
for (BotEmojis emoji : values()) {
48-
jda.retrieveApplicationEmojiById(emoji.emojiId).queue(e -> EMOJI_MAP.put(emoji, e));
49-
}
50-
}
51-
52-
private final String emojiId;
53-
54-
BotEmojis(String emojiId) {
55-
this.emojiId = emojiId;
49+
jda.retrieveApplicationEmojis().queue(emojis -> {
50+
for (BotEmojis emoji : values()) {
51+
EMOJI_MAP.put(emoji, emojis.stream().filter(e -> e.getName().equals(emoji.name().toLowerCase(Locale.ROOT))).findFirst().get());
52+
}
53+
});
5654
}
5755

5856
public Emoji get() {

0 commit comments

Comments
 (0)