Skip to content

[BUG] Emoji doesn't serialize properly #528

@Mayerch1

Description

@Mayerch1

Describe the bug
Emoji objects cannot be passed directly as parameter into other objects.
Mainly the SelectOption will break when trying to pass an emoji.

As a workaround it's possible to use ._json, so this is not an urgent bug.

Reproducing steps
Using the latest unstable build
discord-py-interactions @ git+https://github.com/interactions-py/library@9fec46cfd7eaf39e1f7d83a7f6186c6dc8d2c1cb

The following minimal working example will break when creating the SelectOption object

import interactions

emoji = interactions.Emoji(name='rogue', id='625891304148303894')
option = interactions.SelectOption(
        label='Overview Page',
        description='List all available commands',
        emoji=emoji,
        value='overview',
        default=True
    )

print(option)

It's possible to just pass emoji._json instead without issues, but I would expect the lib to accept the Emoji-object as well (according to docs).

emoji? (Optional[Emoji]) – The emoji used alongside the label of the select option.

What's normally expected
The object should be created and printed to console.

What actually happened
The application crashes with the given stack-trace

Traceback (most recent call last):
   ...
  File "f:\Christian\Documents\Code\Python\Test\test.py", line 5, in <module>
    option = interactions.SelectOption(
  File "C:\Users\Christian\AppData\Local\Programs\Python\Python39\lib\site-packages\interactions\models\component.py", line 38, in __init__
    self.emoji = Emoji(**self.emoji) if self._json.get("emoji") else None
TypeError: interactions.api.models.message.Emoji() argument after ** must be a mapping, not Emoji

Versions

  • I am using discord.py versions 1.7 and below with my code.
    • I am using 2.0 or higher, or a modified fork.
  • I am using dis-snek with my code.
  • I am not using any of the listed above and am using the library code alone.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

Status

Complete

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions