mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-05-18 11:45:37 +00:00
Fix Guild.vanity_invite causing an error when guild has it unset
FIx #7103
This commit is contained in:
parent
5acea453cc
commit
a75cd93acc
@ -2407,7 +2407,7 @@ class Guild(Hashable):
|
|||||||
"""
|
"""
|
||||||
await self._state.http.unban(user.id, self.id, reason=reason)
|
await self._state.http.unban(user.id, self.id, reason=reason)
|
||||||
|
|
||||||
async def vanity_invite(self) -> Invite:
|
async def vanity_invite(self) -> Optional[Invite]:
|
||||||
"""|coro|
|
"""|coro|
|
||||||
|
|
||||||
Returns the guild's special vanity invite.
|
Returns the guild's special vanity invite.
|
||||||
@ -2426,12 +2426,15 @@ class Guild(Hashable):
|
|||||||
|
|
||||||
Returns
|
Returns
|
||||||
--------
|
--------
|
||||||
:class:`Invite`
|
Optional[:class:`Invite`]
|
||||||
The special vanity invite.
|
The special vanity invite. If ``None`` then the guild does not
|
||||||
|
have a vanity invite set.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# we start with { code: abc }
|
# we start with { code: abc }
|
||||||
payload = await self._state.http.get_vanity_code(self.id)
|
payload = await self._state.http.get_vanity_code(self.id)
|
||||||
|
if not payload['code']:
|
||||||
|
return None
|
||||||
|
|
||||||
# get the vanity URL channel since default channels aren't
|
# get the vanity URL channel since default channels aren't
|
||||||
# reliable or a thing anymore
|
# reliable or a thing anymore
|
||||||
@ -2442,6 +2445,7 @@ class Guild(Hashable):
|
|||||||
payload['temporary'] = False
|
payload['temporary'] = False
|
||||||
payload['max_uses'] = 0
|
payload['max_uses'] = 0
|
||||||
payload['max_age'] = 0
|
payload['max_age'] = 0
|
||||||
|
payload['uses'] = payload.get('uses', 0)
|
||||||
return Invite(state=self._state, data=payload, guild=self, channel=channel)
|
return Invite(state=self._state, data=payload, guild=self, channel=channel)
|
||||||
|
|
||||||
# TODO: use MISSING when async iterators get refactored
|
# TODO: use MISSING when async iterators get refactored
|
||||||
|
Loading…
x
Reference in New Issue
Block a user