Package net.dv8tion.jda.api.entities
Interface Invite
-
public interface InviteRepresentation of a Discord Invite. This class is immutable.- Since:
- 3.0
- Author:
- Aljoscha Grebe
- See Also:
resolve(JDA, String),resolve(JDA, String, boolean),Guild.retrieveInvites(),GuildChannel.retrieveInvites()
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceInvite.ChannelPOJO for the channel information provided by an invite.static interfaceInvite.EmbeddedApplicationPOJO for the target application information provided by an invite.static interfaceInvite.GroupPOJO for the group information provided by an invite.static interfaceInvite.GuildPOJO for the guild information provided by an invite.static interfaceInvite.InviteTargetPOJO for the target of this invite.static classInvite.InviteTypeEnum representing the type of an invite.static classInvite.TargetTypeA TargetType indicates additional action to be taken by the client on accepting the invite, typically connecting external services or launching external applications depending on the specific TargetType.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description AuditableRestAction<java.lang.Void>delete()Deletes this invite.RestAction<Invite>expand()Tries to retrieve a new expandedInvitewith more info.Invite.ChannelgetChannel()AnInvite.Channelobject containing information about this invite's origin channel.java.lang.StringgetCode()The invite codejava.time.OffsetDateTimegetCreationTime()Deprecated.UsegetTimeCreated()insteadInvite.GroupgetGroup()AnInvite.Groupobject containing information about this invite's origin group.Invite.GuildgetGuild()AnInvite.Guildobject containing information about this invite's origin guild.UsergetInviter()The user who created this invite.JDAgetJDA()TheJDAinstance used to create this InviteintgetMaxAge()The max age of this invite in seconds.intgetMaxUses()The max uses of this invite.Invite.InviteTargetgetTarget()AnInvite.InviteTargetobject containing information about this invite's target ornullif this invite does not have a target.Invite.TargetTypegetTargetType()The target type of this invite orInvite.TargetType.NONEif this invite does not have aInviteTarget.java.time.OffsetDateTimegetTimeCreated()Returns creation date of this invite.Invite.InviteTypegetType()The type of this invite.default java.lang.StringgetUrl()The invite URL for this invite in the format of:"https://discord.gg/" + getCode()intgetUses()How often this invite has been used.booleanisExpanded()Whether this Invite is expanded or not.booleanisTemporary()Whether this Invite grants only temporary access or not.static RestAction<Invite>resolve(JDA api, java.lang.String code)Retrieves a newInviteinstance for the given invite code.static RestAction<Invite>resolve(JDA api, java.lang.String code, boolean withCounts)Retrieves a newInviteinstance for the given invite code.
-
-
-
Method Detail
-
resolve
@Nonnull static RestAction<Invite> resolve(@Nonnull JDA api, @Nonnull java.lang.String code)
Retrieves a newInviteinstance for the given invite code.
You cannot resolve invites if you were banned from the origin Guild!Possible
ErrorResponsesinclude:Unknown Invite
The Invite did not exist (possibly deleted) or the account is banned in the guild.
- Parameters:
api- The JDA instancecode- A valid invite code- Returns:
RestAction- Type:Invite
The Invite object
-
resolve
@Nonnull static RestAction<Invite> resolve(@Nonnull JDA api, @Nonnull java.lang.String code, boolean withCounts)
Retrieves a newInviteinstance for the given invite code.
You cannot resolve invites if you were banned from the origin Guild!Possible
ErrorResponsesinclude:Unknown Invite
The Invite did not exist (possibly deleted) or the account is banned in the guild.
- Parameters:
api- The JDA instancecode- A valid invite codewithCounts- Whether or not to include online and member counts for guild invites or users for group invites- Returns:
RestAction- Type:Invite
The Invite object
-
delete
@Nonnull @CheckReturnValue AuditableRestAction<java.lang.Void> delete()
Deletes this invite.
RequiresMANAGE_CHANNELin the invite's channel. Will throw anInsufficientPermissionExceptionotherwise.- Returns:
AuditableRestAction- Throws:
InsufficientPermissionException- if the account does not haveMANAGE_SERVERin the invite's channel
-
expand
@Nonnull @CheckReturnValue RestAction<Invite> expand()
Tries to retrieve a new expandedInvitewith more info.
As bots can't be in groups this is only available for guild invites and will throw anIllegalStateExceptionfor other types.
Requires eitherMANAGE_SERVERin the invite's guild orMANAGE_CHANNELin the invite's channel. Will throw anInsufficientPermissionExceptionotherwise.- Returns:
RestAction- Type:Invite
The expanded Invite object- Throws:
InsufficientPermissionException- if the account neither hasMANAGE_SERVERin the invite's guild norMANAGE_CHANNELin the invite's channeljava.lang.IllegalStateException- If this is a group invite- See Also:
getType(),isExpanded()
-
getType
@Nonnull Invite.InviteType getType()
The type of this invite.- Returns:
- The invite's type
-
getTargetType
@Nonnull Invite.TargetType getTargetType()
The target type of this invite orInvite.TargetType.NONEif this invite does not have aInviteTarget.- Returns:
- The invite's target type or
Invite.TargetType.NONE - See Also:
Invite.TargetType
-
getChannel
@Nullable Invite.Channel getChannel()
AnInvite.Channelobject 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
-
getGroup
@Nullable Invite.Group getGroup()
AnInvite.Groupobject 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
-
getTarget
@Nullable Invite.InviteTarget getTarget()
AnInvite.InviteTargetobject containing information about this invite's target ornullif this invite does not have a target.- Returns:
- Information about this invite's target or
null - See Also:
Invite.InviteTarget
-
getCode
@Nonnull java.lang.String getCode()
The invite code- Returns:
- the invite code
-
getUrl
@Nonnull 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
@Nonnull @Deprecated @ForRemoval(deadline="5.0.0") @DeprecatedSince("4.0.0") @ReplaceWith("getTimeCreated()") java.time.OffsetDateTime getCreationTime()
Deprecated.UsegetTimeCreated()insteadReturns creation date of this invite.This works only for expanded invites and will throw a
IllegalStateExceptionotherwise!- Returns:
- The creation date of this invite
- Throws:
java.lang.IllegalStateException- if this invite is not expanded- See Also:
expand(),isExpanded()
-
getGuild
@Nullable Invite.Guild getGuild()
AnInvite.Guildobject 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
@Nullable User getInviter()
The user who created this invite. For not expanded invites this may be null.- Returns:
- The user who created this invite
-
getJDA
@Nonnull JDA getJDA()
TheJDAinstance 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
IllegalStateExceptionotherwise!- 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 return0.This works only for expanded invites and will throw a
IllegalStateExceptionotherwise!- Returns:
- The max uses of this invite or
0if there is no limit - Throws:
java.lang.IllegalStateException- if this invite is not expanded- See Also:
expand(),isExpanded()
-
getTimeCreated
@Nonnull java.time.OffsetDateTime getTimeCreated()
Returns creation date of this invite.This works only for expanded invites and will throw a
IllegalStateExceptionotherwise!- Returns:
- The creation date of this invite
- 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
IllegalStateExceptionotherwise!- Returns:
- The uses of this invite
- Throws:
java.lang.IllegalStateException- if this invite is not expanded- See Also:
expand(),isExpanded()
-
isExpanded
boolean isExpanded()
Whether this Invite is expanded or not. Expanded invites contain more information, but they can only be obtained byGuild#retrieveInvites()(requiresPermission.MANAGE_SERVER) orGuildChannel#retrieveInvites()(requiresPermission.MANAGE_CHANNEL).There is a convenience method
expand()to get the expanded invite for an unexpanded one.- Returns:
- Whether this invite is expanded or not
- See Also:
expand()
-
isTemporary
boolean isTemporary()
Whether this Invite grants only temporary access or not.This works only for expanded invites and will throw a
IllegalStateExceptionotherwise!- Returns:
- Whether this invite is temporary or not
- Throws:
java.lang.IllegalStateException- if this invite is not expanded- See Also:
expand(),isExpanded()
-
-