aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--discord/client.py11
-rw-r--r--discord/invite.py8
2 files changed, 18 insertions, 1 deletions
diff --git a/discord/client.py b/discord/client.py
index 8b7965bb..5789482c 100644
--- a/discord/client.py
+++ b/discord/client.py
@@ -748,3 +748,14 @@ class Client(object):
return Invite(**data)
return None
+
+ def accept_invite(self, invite):
+ """Accepts an :class:`Invite`.
+
+ :param invite: The :class:`Invite` to accept.
+ :returns: True if the invite was successfully accepted, False otherwise.
+ """
+
+ url = '{0}/invite/{1.id}'.format(endpoints.API_BASE, invite)
+ response = requests.post(url, headers=self.headers)
+ return response.status_code in (200, 201)
diff --git a/discord/invite.py b/discord/invite.py
index 39897b44..24af7ce2 100644
--- a/discord/invite.py
+++ b/discord/invite.py
@@ -81,6 +81,12 @@ class Invite(object):
self.channel = kwargs.get('channel')
@property
+ def id(self):
+ """Returns the proper code portion of the invite."""
+ return self.xkcd if self.xkcd else self.code
+
+ @property
def url(self):
"""A property that retrieves the invite URL."""
- return 'http://discord.gg/{}'.format(self.xkcd if self.xkcd else self.code)
+ return 'http://discord.gg/{}'.format(self.id)
+