diff options
| author | Gorialis <[email protected]> | 2018-01-02 07:59:51 +0900 |
|---|---|---|
| committer | Rapptz <[email protected]> | 2018-01-06 17:32:25 -0500 |
| commit | 04d9dd9c0dc82b4d870c6269ecc3a9e46cd7292e (patch) | |
| tree | 4f3060a57302181cf9287786be2655aad5f985a0 /discord/ext | |
| parent | Add intersphinx (diff) | |
| download | discord.py-04d9dd9c0dc82b4d870c6269ecc3a9e46cd7292e.tar.xz discord.py-04d9dd9c0dc82b4d870c6269ecc3a9e46cd7292e.zip | |
Change PartialReactionEmoji to PartialEmoji, add a PartialEmojiConverter
Diffstat (limited to 'discord/ext')
| -rw-r--r-- | discord/ext/commands/converter.py | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/discord/ext/commands/converter.py b/discord/ext/commands/converter.py index e2397ad2..9e3718b0 100644 --- a/discord/ext/commands/converter.py +++ b/discord/ext/commands/converter.py @@ -35,8 +35,8 @@ from .view import StringView __all__ = [ 'Converter', 'MemberConverter', 'UserConverter', 'TextChannelConverter', 'InviteConverter', 'RoleConverter', 'GameConverter', 'ColourConverter', 'VoiceChannelConverter', - 'EmojiConverter','CategoryChannelConverter', 'IDConverter', - 'clean_content' ] + 'EmojiConverter', 'PartialEmojiConverter', 'CategoryChannelConverter', + 'IDConverter', 'clean_content' ] def _get_from_guilds(bot, getter, argument): result = None @@ -397,6 +397,25 @@ class EmojiConverter(IDConverter): return result +class PartialEmojiConverter(Converter): + """Converts to a :class:`PartialEmoji`. + + + This is done by extracting the animated flag, name and ID from the emoji. + """ + @asyncio.coroutine + 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(animated=emoji_animated, name=emoji_name, id=emoji_id) + + raise BadArgument('Couldn\'t convert "{}" to PartialEmoji.'.format(argument)) + class clean_content(Converter): """Converts the argument to mention scrubbed version of said content. |