Discord.py: Error when setting emoji in the CustomActivity

Created on 30 Apr 2020  路  5Comments  路  Source: Rapptz/discord.py

Summary

I'm trying to set a custom activity and getting an error.

Reproduction Steps

            cs = discord.CustomActivity(name="Custom status lol :P", emoji=discord.PartialEmoji(name='馃'))
            await self.client.change_presence(activity=cs)

Expected Results

The status will be set.

Actual Results

First try with PartialEmoji (as seen in the docs):

Traceback (most recent call last):
  File "/Users/nemetharon/Desktop/FightMan01_bot/1.2.3/cogs/status.py", line 30, in on_status_ready
    cs = discord.CustomActivity(name="Custom status lol :P", emoji=discord.PartialEmoji(name='馃'))
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/discord/activity.py", line 696, in __init__
    self.emoji = PartialEmoji.from_dict(emoji)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/discord/partial_emoji.py", line 80, in from_dict
    return cls(animated=data.get('animated', False), id=data.get('id'), name=data.get('name'))
AttributeError: 'PartialEmoji' object has no attribute 'get'

Second try with a simple string:

Traceback (most recent call last):
  File "/Users/nemetharon/Desktop/FightMan01_bot/1.2.3/cogs/status.py", line 30, in on_status_ready
    cs = discord.CustomActivity(name="Custom status lol :P", emoji='馃')
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/discord/activity.py", line 696, in __init__
    self.emoji = PartialEmoji.from_dict(emoji)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/discord/partial_emoji.py", line 80, in from_dict
    return cls(animated=data.get('animated', False), id=data.get('id'), name=data.get('name'))
AttributeError: 'str' object has no attribute 'get'

Checklist

  • [x] I have searched the open issues for duplicates.
  • [x] I have shown the entire traceback, if possible.
  • [x] I have removed my token from display, if visible.

System Information

  • Python v3.8.2-final
  • discord.py v1.3.3-final
  • aiohttp v3.6.2
  • websockets v6.0
  • system info: Darwin 19.4.0 Darwin Kernel Version 19.4.0: Wed Mar 4 22:28:40 PST 2020; root:xnu-6153.101.6~15/RELEASE_X86_64

All 5 comments

Bots can't have a custom statuses, but that said, this is either a documentation error or lib bug, as indeed, this doesn't work.

Indeed, this is a bug caused by this line. The documentation says that the emoji parameter receives an object of type PartialEmoji (as you did), but, in fact, it should receive a dict data to PartialEmoji.from_dict create the object itself.

Again, bots can't have a custom status, so you cannot run your code without having an error

Even though bots cannot have emojis in CustomActivity, the error he gets does not match the documentation.

Thank you for the reply!
I just tried it.
But I think the docs should be inform me about it.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Nicba1010 picture Nicba1010  路  3Comments

JackL0 picture JackL0  路  3Comments

superloach picture superloach  路  3Comments

PicklesJars picture PicklesJars  路  3Comments

AraHaan picture AraHaan  路  3Comments