[docs]classPartialInvite:BASE="https://discord.gg"def__init__(self,*,state:"DiscordAPI",code:str,channel_id:int|None=None,guild_id:int|None=None):self._state=stateself.code=codeself.channel_id=channel_idself.guild_id=guild_iddef__str__(self)->str:returnself.urldef__repr__(self)->str:returnf"<PartialInvite code='{self.code}'>"@propertydefguild(self)->Guild|PartialGuild|None:""" `Optional[PartialGuild]`: The guild the invite is in """ifnotself.guild_id:returnNonecache=self._state.cache.get_guild(self.guild_id)ifcache:returncachereturnPartialGuild(state=self._state,id=self.guild_id)@propertydefchannel(self)->"PartialChannel | None":""" `Optional[PartialChannel]`: The channel the invite is in """ifnotself.channel_id:returnNonereturnPartialChannel(state=self._state,id=self.channel_id,guild_id=self.guild_id)
[docs]asyncdeffetch(self)->"Invite":""" Fetches the invite details Returns ------- `Invite` The invite object """r=awaitself._state.query("GET",f"/invites/{self.code}")returnInvite(state=self._state,data=r.response)
[docs]asyncdefdelete(self,*,reason:str|None=None)->"Invite":""" Deletes the invite Parameters ---------- reason: `str` The reason for deleting the invite Returns ------- `Invite` The invite object """data=awaitself._state.query("DELETE",f"/invites/{self.code}",reason=reason)returnInvite(state=self._state,data=data.response)
@propertydefurl(self)->str:""" `str`: The URL of the invite """returnf"{self.BASE}/{self.code}"
[docs]defis_vanity(self)->bool:""" `bool`: Whether the invite is a vanity invite """ifnotself.guild:returnFalseifnotisinstance(self.guild,Guild):returnFalsereturnself.guild.vanity_url_code==self.code