aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRapptz <[email protected]>2015-09-03 06:41:35 -0400
committerRapptz <[email protected]>2015-09-03 06:41:35 -0400
commit54fa8dea696cff8d74080c4936a17c8073562ddb (patch)
tree553227417733f5f08c72aab4be83c6d695cb4adb
parentAdd on_server_create and on_server_delete events. (diff)
downloaddiscord.py-54fa8dea696cff8d74080c4936a17c8073562ddb.tar.xz
discord.py-54fa8dea696cff8d74080c4936a17c8073562ddb.zip
Add the ability to kick, ban and unban users from a server.
-rw-r--r--discord/client.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/discord/client.py b/discord/client.py
index fa87c521..173928da 100644
--- a/discord/client.py
+++ b/discord/client.py
@@ -576,3 +576,38 @@ class Client(object):
url = '{}/{}'.format(endpoints.CHANNELS, channel.id)
response = requests.delete(url, headers=self.headers)
+ def kick(self, server, user):
+ """Kicks a :class:`User` from their respective :class:`Server`.
+
+ You must have the proper permissions to kick a user in the server.
+
+ :param server: The :class:`Server` to kick the member from.
+ :param user: The :class:`User` to kick.
+ """
+
+ url = '{base}/{server}/members/{user}'.format(base=endpoints.SERVERS, server=server.id, user=user.id)
+ response = requests.delete(url, headers=self.headers)
+
+ def ban(self, server, user):
+ """Bans a :class:`User` from their respective :class:`Server`.
+
+ You must have the proper permissions to ban a user in the server.
+
+ :param server: The :class:`Server` to ban the member from.
+ :param user: The :class:`User` to ban.
+ """
+
+ url = '{base}/{server}/bans/{user}'.format(base=endpoints.SERVERS, server=server.id, user=user.id)
+ response = requests.put(url, headers=self.headers)
+
+ def unban(self, server, name):
+ """Unbans a :class:`User` from their respective :class:`Server`.
+
+ You must have the proper permissions to unban a user in the server.
+
+ :param server: The :class:`Server` to unban the member from.
+ :param user: The :class:`User` to unban.
+ """
+
+ url = '{base}/{server}/bans/{user}'.format(base=endpoints.SERVERS, server=server.id, user=user.id)
+ response = requests.delete(url, headers=self.headers)