Skip to content

discord.customActivity emoji type #279

Answered by TheOnlyWayUp
tchavei asked this question in Help
Discussion options

You must be logged in to vote
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 …

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@dolfies
Comment options

Answer selected by dolfies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
3 participants