mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-06-06 20:07:17 +00:00
Add support for setting and retrieving guild vanity invites.
This commit is contained in:
parent
86b9099f3a
commit
ba2dad2093
@ -1003,6 +1003,61 @@ class Guild(Hashable):
|
||||
"""
|
||||
yield from self._state.http.unban(user.id, self.id)
|
||||
|
||||
@asyncio.coroutine
|
||||
def vanity_invite(self):
|
||||
"""|coro|
|
||||
|
||||
Returns the guild's special vanity invite.
|
||||
|
||||
The guild must be partnered, i.e. have 'VANITY_URL' in
|
||||
:attr:`~Guild.features`.
|
||||
|
||||
You must have :attr:`Permissions.manage_guild` to use this as well.
|
||||
|
||||
Returns
|
||||
--------
|
||||
:class:`Invite`
|
||||
The special vanity invite.
|
||||
|
||||
Raises
|
||||
-------
|
||||
Forbidden
|
||||
You do not have the proper permissions to get this.
|
||||
HTTPException
|
||||
Retrieving the vanity invite failed.
|
||||
"""
|
||||
|
||||
# we start with { code: abc }
|
||||
payload = yield from self._state.http.get_vanity_code(self.id)
|
||||
payload['guild'] = self
|
||||
payload['channel'] = self.default_channel
|
||||
payload['revoked'] = False
|
||||
payload['temporary'] = False
|
||||
payload['max_uses'] = 0
|
||||
payload['max_age'] = 0
|
||||
return Invite(state=self._state, data=payload)
|
||||
|
||||
@asyncio.coroutine
|
||||
def change_vanity_invite(self, new_code):
|
||||
"""|coro|
|
||||
|
||||
Changes the guild's special vanity invite.
|
||||
|
||||
The guild must be partnered, i.e. have 'VANITY_URL' in
|
||||
:attr:`~Guild.features`.
|
||||
|
||||
You must have :attr:`Permissions.manage_guild` to use this as well.
|
||||
|
||||
Raises
|
||||
-------
|
||||
Forbidden
|
||||
You do not have the proper permissions to set this.
|
||||
HTTPException
|
||||
Setting the vanity invite failed.
|
||||
"""
|
||||
|
||||
yield from self._state.http.change_vanity_code(self.id, new_code)
|
||||
|
||||
def ack(self):
|
||||
"""|coro|
|
||||
|
||||
|
@ -531,6 +531,13 @@ class HTTPClient:
|
||||
def get_bans(self, guild_id):
|
||||
return self.request(Route('GET', '/guilds/{guild_id}/bans', guild_id=guild_id))
|
||||
|
||||
def get_vanity_code(self, guild_id):
|
||||
return self.request(Route('GET', '/guilds/{guild_id}/vanity-url', guild_id=guild_id))
|
||||
|
||||
def change_vanity_code(self, guild_id, code):
|
||||
payload = { 'code': code }
|
||||
return self.request(Route('PATCH', '/guilds/{guild_id}/vanity-url', guild_id=guild_id), json=payload)
|
||||
|
||||
def prune_members(self, guild_id, days):
|
||||
params = {
|
||||
'days': days
|
||||
|
@ -1320,6 +1320,8 @@ this goal, it must make use of a couple of data classes that aid in this goal.
|
||||
|
||||
*str* – The guild's vanity URL.
|
||||
|
||||
See also :meth:`Guild.vanity_invite` and :meth:`Guild.change_vanity_invite`.
|
||||
|
||||
.. attribute:: position
|
||||
|
||||
*int* – The position of a :class:`Role` or :class:`abc.GuildChannel`.
|
||||
|
Loading…
x
Reference in New Issue
Block a user