Interface Invite


  • public interface Invite
    Representation of a Discord Invite. This class is immutable.
    Since:
    3.0
    Author:
    Aljoscha Grebe
    • Method Detail

      • resolve

        static RestAction<Invite> resolve​(JDA api,
                                          java.lang.String code)
        Retrieves a new Invite instance for the given invite code.
        You cannot resolve invites if you were banned from the origin Guild!

        Possible ErrorResponses include:

        • Unknown Invite
          The Invite did not exist (possibly deleted) or the account is banned in the guild.
        Parameters:
        api - The JDA instance
        code - A valid invite code
        Returns:
        RestAction - Type: Invite
        The Invite object
      • resolve

        static RestAction<Invite> resolve​(JDA api,
                                          java.lang.String code,
                                          boolean withCounts)
        Retrieves a new Invite instance for the given invite code.
        You cannot resolve invites if you were banned from the origin Guild!

        Possible ErrorResponses include:

        • Unknown Invite
          The Invite did not exist (possibly deleted) or the account is banned in the guild.
        Parameters:
        api - The JDA instance
        code - A valid invite code
        withCounts - Whether or not to include online and member counts for guild invites or users for group invites
        Returns:
        RestAction - Type: Invite
        The Invite object
      • getType

        Invite.InviteType getType()
        The type of this invite.
        Returns:
        The invites's type
      • getChannel

        Invite.Channel getChannel()
        An Invite.Channel object containing information about this invite's origin channel.
        Returns:
        Information about this invite's origin channel or null in case of a group invite
        See Also:
        Invite.Channel
      • getCode

        java.lang.String getCode()
        The invite code
        Returns:
        the invite code
      • getGroup

        Invite.Group getGroup()
        An Invite.Group object containing information about this invite's origin group.
        Returns:
        Information about this invite's origin group or null in case of a guild invite
        See Also:
        Invite.Group
      • getURL

        default java.lang.String getURL()
        The invite URL for this invite in the format of: "https://discord.gg/" + getCode()
        Returns:
        Invite URL for this Invite
      • getCreationTime

        java.time.OffsetDateTime getCreationTime()
        Returns creation date of this invite.

        This works only for expanded invites and will throw a IllegalStateException otherwise!

        Returns:
        The creation date of this invite
        Throws:
        java.lang.IllegalStateException - if this invite is not expanded
        See Also:
        expand(), isExpanded()
      • getGuild

        Invite.Guild getGuild()
        An Invite.Guild object containing information about this invite's origin guild.
        Returns:
        Information about this invite's origin guild or null in case of a group invite
        See Also:
        Invite.Guild
      • getInviter

        User getInviter()
        The user who created this invite. This may be a fake user. For not expanded invites this may be null.
        Returns:
        The user who created this invite
      • getJDA

        JDA getJDA()
        The JDA instance used to create this Invite
        Returns:
        the corresponding JDA instance
      • getMaxAge

        int getMaxAge()
        The max age of this invite in seconds.

        This works only for expanded invites and will throw a IllegalStateException otherwise!

        Returns:
        The max age of this invite in seconds
        Throws:
        java.lang.IllegalStateException - if this invite is not expanded
        See Also:
        expand(), isExpanded()
      • getMaxUses

        int getMaxUses()
        The max uses of this invite. If there is no limit thus will return 0.

        This works only for expanded invites and will throw a IllegalStateException otherwise!

        Returns:
        The max uses of this invite or 0 if there is no limit
        Throws:
        java.lang.IllegalStateException - if this invite is not expanded
        See Also:
        expand(), isExpanded()
      • getUses

        int getUses()
        How often this invite has been used.

        This works only for expanded invites and will throw a IllegalStateException otherwise!

        Returns:
        The uses of this invite
        Throws:
        java.lang.IllegalStateException - if this invite is not expanded
        See Also:
        expand(), isExpanded()
      • isTemporary

        boolean isTemporary()
        Whether this Invite grants only temporary access or not
        Returns:
        Whether is invite expanded or not
        Throws:
        java.lang.IllegalStateException - if this invite is not expanded