Skip to content

fix(emoji): render a standard emoji for the reaction endpoints - #15

Merged
mikield merged 1 commit into
masterfrom
fix/emoji-builder-unicode
Sep 2, 2026
Merged

mikield merged 1 commit into
masterfrom
fix/emoji-builder-unicode

Conversation

@mikield

@mikield mikield commented Sep 2, 2026

Copy link
Copy Markdown
Member

EmojiBuilder::__toString() renders a standard emoji held under name as:

✅:

— the name, a colon, and an id that is not there. Every reaction on a standard emoji is a malformed request, and PHP warns about the undefined key on the way out.

public function __toString(): string
{
    return isset($this->data['name'])
        ? $this->data['name'] . ':' . $this->data['id']   // ← id may not exist
        : urlencode($this->data['id']);
}

The two halves of the library disagree about where a standard emoji lives. fromPart() copies name and skips id, because that is what Discord sends in a reaction event — so a builder made from a real event is exactly the case that cannot be rendered. The existing test wrote the emoji into setId() instead, which takes the other branch, which is why this held.

Both shapes work now, and the pair is what marks a custom emoji:

name id renders as
apex 12345 apex:12345
✅ — %E2%9C%85
— ✅ %E2%9C%85

Found while porting a bot that votes on petitions with ✅ and ❌ reactions.

🤖 Generated with Claude Code

EmojiBuilder rendered a standard emoji held under name as "✅:" — the
name, a colon, and an id that was not there — which made every reaction
on a standard emoji a malformed request, with an undefined array key
warning on the way out.

Standard emoji arrive under name, since that is where Discord puts them
in a reaction event and therefore what fromPart() copies across. They
were only ever rendered correctly when written by hand into setId(),
which is the shape the existing test used and the reason this held.

Both keys now work, and the pair is what marks a custom emoji.
@mikield
mikield merged commit c57b1d5 into master Sep 2, 2026
4 checks passed
@mikield
mikield deleted the fix/emoji-builder-unicode branch September 2, 2026 02:29
github-actions Bot pushed a commit that referenced this pull request Sep 2, 2026
## [1.3.2](v1.3.1...v1.3.2) (2026-09-02)

### Bug Fixes

* **emoji:** render a standard emoji for the reaction endpoints ([#15](#15)) ([c57b1d5](c57b1d5))
@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown

🎉 This PR is included in version 1.3.2 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant