discord.customActivity emoji type #279
-
I'm trying to set a custom emoji on defining a customActivity like:
This works perfectly. However, when trying to use a custom emoji, it fails. So far I tried: What am I doing wrong? tl;dr unicode emoji work, custom don't. They do work if injected directly into the api with another lib but would like to avoid that Thank you |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
def convert(self, ctx, argument):
match = re.match(r'<(a?):([a-zA-Z0-9\_]+):([0-9]+)>$', argument)
if match:
emoji_animated = bool(match.group(1))
emoji_name = match.group(2)
emoji_id = int(match.group(3))
return discord.PartialEmoji.with_state(ctx.bot._connection, animated=emoji_animated, name=emoji_name,
id=emoji_id)
raise BadArgument('Couldn\'t convert "{}" to PartialEmoji.'.format(argument)) I've never used PartialEmoji, but this converter (used in typehints usually) essentially just converts an emoji string into a discord.PartialEmoji object. You can use this snippet to return such an object def get_partial_emoji(ctx, emoji_string):
match = re.match(r'<(a?):([a-zA-Z0-9\_]+):([0-9]+)>$', emoji_string)
if match:
emoji_animated = bool(match.group(1))
emoji_name = match.group(2)
emoji_id = int(match.group(3))
return discord.PartialEmoji(name=emoji_name, id=emoji_id, animated=emoji_animated) Edit: Fixed the snippet after Dolfies's comment |
Beta Was this translation helpful? Give feedback.
I've never used PartialEmoji, but this converter (used in typehints usually) essentially just converts an emoji string into a discord.PartialEmoji object.
You can use this …