aboutsummaryrefslogtreecommitdiff
path: root/discord/utils.py
diff options
context:
space:
mode:
authorRapptz <[email protected]>2016-09-26 19:54:52 -0400
committerRapptz <[email protected]>2016-09-26 19:55:42 -0400
commit7272190e2db6def1f8a6e153775b33c95d62e7bf (patch)
tree062d206d51b9abbeb8da42035b7c383a8eb91386 /discord/utils.py
parentRemove unused endpoints.py file. (diff)
downloaddiscord.py-7272190e2db6def1f8a6e153775b33c95d62e7bf.tar.xz
discord.py-7272190e2db6def1f8a6e153775b33c95d62e7bf.zip
Add support for "Do Not Disturb" and "Invisible" statuses.
This deprecates Client.change_status in favour of the newer and more correct Client.change_presence.
Diffstat (limited to 'discord/utils.py')
-rw-r--r--discord/utils.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/discord/utils.py b/discord/utils.py
index 55ee30a8..83129654 100644
--- a/discord/utils.py
+++ b/discord/utils.py
@@ -30,6 +30,7 @@ import datetime
from base64 import b64encode
import asyncio
import json
+import warnings, functools
DISCORD_EPOCH = 1420070400000
@@ -74,6 +75,21 @@ def parse_time(timestamp):
return datetime.datetime(*map(int, re_split(r'[^\d]', timestamp.replace('+00:00', ''))))
return None
+def deprecated(instead=None):
+ def actual_decorator(func):
+ @functools.wraps(func)
+ def decorated(*args, **kwargs):
+ warnings.simplefilter('always', DeprecationWarning) # turn off filter
+ if instead:
+ fmt = "{0.__name__} is deprecated, use {1} instead."
+ else:
+ fmt = '{0.__name__} is deprecated.'
+
+ warnings.warn(fmt.format(func, instead), stacklevel=3, category=DeprecationWarning)
+ warnings.simplefilter('default', DeprecationWarning) # reset filter
+ return func(*args, **kwargs)
+ return decorated
+ return actual_decorator
def oauth_url(client_id, permissions=None, server=None, redirect_uri=None):
"""A helper function that returns the OAuth2 URL for inviting the bot