diff options
| author | Rapptz <[email protected]> | 2016-11-05 16:57:52 -0400 |
|---|---|---|
| committer | Rapptz <[email protected]> | 2017-01-03 09:51:55 -0500 |
| commit | 5cb3ad14e8501961c2684498682bfb4e0fb016ff (patch) | |
| tree | 29d314d03844af9359fb47f3f7ab3c90aaf76ab1 /discord/guild.py | |
| parent | Make roles and guilds stateful. (diff) | |
| download | discord.py-5cb3ad14e8501961c2684498682bfb4e0fb016ff.tar.xz discord.py-5cb3ad14e8501961c2684498682bfb4e0fb016ff.zip | |
Make emojis and members stateful.
Diffstat (limited to 'discord/guild.py')
| -rw-r--r-- | discord/guild.py | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/discord/guild.py b/discord/guild.py index 6e37c3ab..3ed07b20 100644 --- a/discord/guild.py +++ b/discord/guild.py @@ -680,3 +680,81 @@ class Guild(Hashable): # TODO: add to cache return role + + @asyncio.coroutine + def kick(self, user): + """|coro| + + Kicks a user from the guild. + + The user must meet the :class:`abc.Snowflake` abc. + + You must have :attr:`Permissions.kick_members` permissions to + do this. + + Parameters + ----------- + user: :class:`abc.Snowflake` + The user to kick from their guild. + + Raises + ------- + Forbidden + You do not have the proper permissions to kick. + HTTPException + Kicking failed. + """ + yield from self._state.http.kick(user.id, self.id) + + @asyncio.coroutine + def ban(self, user, *, delete_message_days=1): + """|coro| + + Bans a user from the guild. + + The user must meet the :class:`abc.Snowflake` abc. + + You must have :attr:`Permissions.ban_members` permissions to + do this. + + Parameters + ----------- + user: :class:`abc.Snowflake` + The user to ban from their guild. + delete_message_days: int + The number of days worth of messages to delete from the user + in the guild. The minimum is 0 and the maximum is 7. + + Raises + ------- + Forbidden + You do not have the proper permissions to ban. + HTTPException + Banning failed. + """ + yield from self._state.http.ban(user.id, self.id, delete_message_days) + + @asyncio.coroutine + def unban(self, user): + """|coro| + + Unbans a user from the guild. + + The user must meet the :class:`abc.Snowflake` abc. + + You must have :attr:`Permissions.ban_members` permissions to + do this. + + Parameters + ----------- + user: :class:`abc.Snowflake` + The user to unban. + + Raises + ------- + Forbidden + You do not have the proper permissions to unban. + HTTPException + Unbanning failed. + """ + yield from self._state.http.unban(user.id, self.id) |