Resolves an invite from a :class:`Invite`, URL or ID

    Parameters
    -----------
    invite: Union[:class:`Invite`, :class:`Object`, :class:`str`]
        The invite.

    Returns
    --------
    :class:`str`
        The invite code.

def resolve_invite(invite):
    """
    Resolves an invite from a :class:`Invite`, URL or ID

    Parameters
    -----------
    invite: Union[:class:`Invite`, :class:`Object`, :class:`str`]
        The invite.

    Returns
    --------
    :class:`str`
        The invite code.
    """
    from .invite import Invite  # circular import
    if isinstance(invite, Invite) or isinstance(invite, Object):
        return invite.id
    else:
        rx = r'(?:https?\:\/\/)?discord(?:\.gg|app\.com\/invite)\/(.+)'
        m = re.match(rx, invite)
        if m:
            return m.group(1)
    return invite