Skip to content

Track emoji usage in messages and reactions#1449

Open
barsh404error wants to merge 1 commit intoTogether-Java:developfrom
barsh404error:feature/metric
Open

Track emoji usage in messages and reactions#1449
barsh404error wants to merge 1 commit intoTogether-Java:developfrom
barsh404error:feature/metric

Conversation

@barsh404error
Copy link
Member

What

Adds EmojiTrackerListener to track emoji usage across messages and reactions.

Why

Closes #1445

How

  • Extended MessageReceiverAdapter and listens to all channels
  • Tracks custom emojis in messages via getMentions().getCustomEmojis()
  • Tracks emojis in reactions via onMessageReactionAdd
  • Custom emojis are identified by Discord ID (not name, since names aren't unique and can change)
  • Animated custom emojis tracked separately under emoji-custom-animated-{id}
  • Unicode emojis tracked by name under emoji-unicode-{name}
  • Registered in Features.java

@barsh404error barsh404error requested a review from a team as a code owner March 25, 2026 16:45
@barsh404error barsh404error self-assigned this Mar 25, 2026

@Override
public void onMessageReceived(MessageReceivedEvent event) {
if (event.getAuthor().isBot() || event.isWebhookMessage()) {
Copy link
Contributor

@surajkumar surajkumar Mar 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove event.getAuthor().isBot() - we want to track our own usage too (later, it'll be a dimension)


@Override
public void onMessageReactionAdd(MessageReactionAddEvent event) {
if (event.getUser() != null && event.getUser().isBot()) {
Copy link
Contributor

@surajkumar surajkumar Mar 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this if-statement since we want to track bots - we don't want to delete emoji's that we use internally after all

}

private void trackEmojiUnion(EmojiUnion emoji) {
if (emoji.getType() == Emoji.Type.CUSTOM) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this if-statement because it's already only going to show custom emoji's because of getCustomEmojis()

if (emoji.getType() == Emoji.Type.CUSTOM) {
trackCustomEmoji(emoji.asCustom());
} else {
metrics.count("emoji-unicode-" + emoji.asUnicode().getName());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this else statement - unicode emoji's won't ever be the case because of getCustomEmojis() and we also don't care about unicode emoji's

Comment on lines +34 to +35
public EmojiTrackerListener(Metrics metrics) {
super(ALL_CHANNELS);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no need for this ALL_CHANNELS, check out the no-arg super constructor from MessageReceiverAdapter :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Emoji Metrics

3 participants