diff options
| author | Rapptz <[email protected]> | 2016-07-13 17:23:35 -0400 |
|---|---|---|
| committer | Rapptz <[email protected]> | 2016-07-13 17:23:35 -0400 |
| commit | 69c506d7aeb9f1a0a6f711b7b8c144f8b554b0d7 (patch) | |
| tree | 5697945188b749ed9db565c7f469d05f0abb93f2 /discord/enums.py | |
| parent | Begin working on gateway v6 changes. (diff) | |
| download | discord.py-69c506d7aeb9f1a0a6f711b7b8c144f8b554b0d7.tar.xz discord.py-69c506d7aeb9f1a0a6f711b7b8c144f8b554b0d7.zip | |
Handle CHANNEL_UPDATE for group direct messages.
Diffstat (limited to 'discord/enums.py')
| -rw-r--r-- | discord/enums.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/discord/enums.py b/discord/enums.py index 10a7f60b..1ae7faf6 100644 --- a/discord/enums.py +++ b/discord/enums.py @@ -73,3 +73,13 @@ class DefaultAvatar(Enum): def __str__(self): return self.name + +def try_enum(cls, val): + """A function that tries to turn the value into enum ``cls``. + + If it fails it returns the value instead. + """ + try: + return cls(val) + except ValueError: + return val |