Package net.dv8tion.jda.api.entities
Interface Invite
public interface Invite
Representation of a Discord Invite.
This class is immutable.
- Since:
- 3.0
- Author:
- Aljoscha Grebe
- See Also:
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic interface
POJO for the channel information provided by an invite.static interface
POJO for the target application information provided by an invite.static interface
POJO for the group information provided by an invite.static interface
POJO for the guild information provided by an invite.static interface
POJO for the target of this invite.static enum
Enum representing the type of an invite.static enum
A 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
Modifier and TypeMethodDescriptiondelete()
Deletes this invite.expand()
Tries to retrieve a new expandedInvite
with more info.AnInvite.Channel
object containing information about this invite's origin channel.getCode()
The invite codegetGroup()
AnInvite.Group
object containing information about this invite's origin group.getGuild()
AnInvite.Guild
object containing information about this invite's origin guild.The user who created this invite.getJDA()
TheJDA
instance used to create this Inviteint
The max age of this invite in seconds.int
The max uses of this invite.AnInvite.InviteTarget
object containing information about this invite's target ornull
if this invite does not have a target.The target type of this invite orInvite.TargetType.NONE
if this invite does not have aInviteTarget
.Returns creation date of this invite.getType()
The type of this invite.default String
getUrl()
The invite URL for this invite in the format of:"https://discord.gg/" + getCode()
int
getUses()
How often this invite has been used.boolean
Whether this Invite is expanded or not.boolean
Whether this Invite grants only temporary access or not.static RestAction
<Invite> Retrieves a newInvite
instance for the given invite code.static RestAction
<Invite> Retrieves a newInvite
instance for the given invite code.
-
Method Details
-
resolve
@Nonnull @CheckReturnValue static RestAction<Invite> resolve(@Nonnull JDA api, @Nonnull String code) Retrieves a newInvite
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 instancecode
- A valid invite code- Returns:
RestAction
- Type:Invite
The Invite object
-
resolve
@Nonnull @CheckReturnValue static RestAction<Invite> resolve(@Nonnull JDA api, @Nonnull String code, boolean withCounts) Retrieves a newInvite
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 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
Deletes this invite.
RequiresMANAGE_CHANNEL
in the invite's channel. Will throw anInsufficientPermissionException
otherwise.- Returns:
AuditableRestAction
- Throws:
InsufficientPermissionException
- if the account does not haveMANAGE_SERVER
in the invite's channel
-
expand
Tries to retrieve a new expandedInvite
with more info.
As bots can't be in groups this is only available for guild invites and will throw anIllegalStateException
for other types.
Requires eitherMANAGE_SERVER
in the invite's guild orMANAGE_CHANNEL
in the invite's channel. Will throw anInsufficientPermissionException
otherwise.- Returns:
RestAction
- Type:Invite
The expanded Invite object- Throws:
InsufficientPermissionException
- if the account neither hasMANAGE_SERVER
in the invite's guild norMANAGE_CHANNEL
in the invite's channelIllegalStateException
- If this is a group invite- See Also:
-
getType
The type of this invite.- Returns:
- The invite's type
-
getTargetType
The target type of this invite orInvite.TargetType.NONE
if this invite does not have aInviteTarget
.- Returns:
- The invite's target type or
Invite.TargetType.NONE
- See Also:
-
getChannel
AnInvite.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:
-
getGroup
AnInvite.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:
-
getTarget
AnInvite.InviteTarget
object containing information about this invite's target ornull
if this invite does not have a target.- Returns:
- Information about this invite's target or
null
- See Also:
-
getCode
The invite code- Returns:
- the invite code
-
getUrl
The invite URL for this invite in the format of:"https://discord.gg/" + getCode()
- Returns:
- Invite URL for this Invite
-
getGuild
AnInvite.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:
-
getInviter
The user who created this invite. For not expanded invites this may be null.- Returns:
- The user who created this invite
-
getJDA
TheJDA
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:
IllegalStateException
- if this invite is not expanded- See Also:
-
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
IllegalStateException
otherwise!- Returns:
- The max uses of this invite or
0
if there is no limit - Throws:
IllegalStateException
- if this invite is not expanded- See Also:
-
getTimeCreated
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:
IllegalStateException
- if this invite is not expanded- See Also:
-
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:
IllegalStateException
- if this invite is not expanded- See Also:
-
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
) orIInviteContainer#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:
-
isTemporary
boolean isTemporary()Whether this Invite grants only temporary access or not.This works only for expanded invites and will throw a
IllegalStateException
otherwise!- Returns:
- Whether this invite is temporary or not
- Throws:
IllegalStateException
- if this invite is not expanded- See Also:
-