public class InviteUtil
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
InviteUtil.AdvancedInvite |
static class |
InviteUtil.Invite |
static class |
InviteUtil.InviteDuration |
Constructor and Description |
---|
InviteUtil() |
Modifier and Type | Method and Description |
---|---|
static InviteUtil.AdvancedInvite |
createInvite(Channel chan)
Creates a standard-invite (valid for 24hrs, infinite usages, permanent access and not human-readable).
|
static InviteUtil.AdvancedInvite |
createInvite(Channel chan,
InviteUtil.InviteDuration duration,
int maxUses,
boolean temporary,
boolean humanReadable)
Creates an advanced invite.
|
static InviteUtil.AdvancedInvite |
createInvite(Channel chan,
JDA jda)
Deprecated.
|
static void |
delete(InviteUtil.Invite invite,
JDA jda)
Tells Discord to delete the specified Invite from the server.
|
static void |
delete(java.lang.String code,
JDA jda)
Tells Discord to delete the specified Invite from the server.
|
static java.util.List<InviteUtil.AdvancedInvite> |
getInvites(Channel channelObj)
|
static java.util.List<InviteUtil.AdvancedInvite> |
getInvites(Guild guildObj)
|
static void |
join(InviteUtil.Invite invite,
JDA jda)
Deprecated.
|
static void |
join(InviteUtil.Invite invite,
JDA jda,
java.util.function.Consumer<Guild> callback)
|
static void |
join(java.lang.String code,
JDA jda)
Deprecated.
|
static void |
join(java.lang.String code,
JDA jda,
java.util.function.Consumer<Guild> callback)
Uses joins the
Guild specified by the provided
invite code/url. |
static InviteUtil.Invite |
resolve(java.lang.String code)
Takes an invite url or invite code and changes it into an
Invite . |
public static InviteUtil.Invite resolve(java.lang.String code)
Invite
.
If the url or code isn't a proper invite, this returns null
code
- The invite url or codeInvite
representing the invite specified by the provided
code or url. This will return null
if the provided code or url is invalid.java.lang.NullPointerException
- If the provided String is null.@Deprecated public static InviteUtil.AdvancedInvite createInvite(Channel chan, JDA jda)
createInvite(net.dv8tion.jda.entities.Channel)
instead.
Creates a standard-invite (valid for 24hrs, infinite usages, permanent access and not human-readable).
To create a customized Invite, use createInvite(Channel, InviteDuration, int, boolean, boolean)
instead.
chan
- The channel to create the invite for.jda
- The JDA-instance from who the invite should be created from.PermissionException
- If the account connected to the provided JDA object does not have
Permission.CREATE_INSTANT_INVITE
for the provided channel.public static InviteUtil.AdvancedInvite createInvite(Channel chan)
createInvite(Channel, InviteDuration, int, boolean, boolean)
instead.chan
- The channel to create the invite for.PermissionException
- If the account connected to the provided JDA object does not have
Permission.CREATE_INSTANT_INVITE
for the provided channel.public static InviteUtil.AdvancedInvite createInvite(Channel chan, InviteUtil.InviteDuration duration, int maxUses, boolean temporary, boolean humanReadable)
chan
- The channel to create the invite for.duration
- The duration the invide should be valid for.maxUses
- The maximum amount of usages of this invite. 0 means infinite usages.temporary
- Whether or not the invite should only grant temporary access to the Guild (members will get removed after they log out, unless they get a role assigned).humanReadable
- Wheter or not the invite should be in human-readable form.PermissionException
- If the account connected to the provided JDA object does not have
Permission.CREATE_INSTANT_INVITE
for the provided channel.@Deprecated public static void join(InviteUtil.Invite invite, JDA jda)
public static void join(InviteUtil.Invite invite, JDA jda, java.util.function.Consumer<Guild> callback)
Guild
specified by the provided
Invite
. Joining invites is always an async process, so you can
provided a Consumer
to define code to be run after the
Guild
is joined.
InviteUtil.join(Invite, JDA, joinedGuild ->
{
System.out.println("I just joined a guild called: " + joinedGuild.getName();
});
Note: If you do not wish to execute any code after joining, provide null
for the consumer.@Deprecated public static void join(java.lang.String code, JDA jda)
public static void join(java.lang.String code, JDA jda, java.util.function.Consumer<Guild> callback)
Guild
specified by the provided
invite code/url. Joining invites is always an async process, so you can
provided a Consumer
to define code to be run after the
Guild
is joined.
InviteUtil.join(Invite, JDA, joinedGuild ->
{
System.out.println("I just joined a guild called: " + joinedGuild.getName();
});
Note: If you do not wish to execute any code after joining, provide null
for the consumer.public static void delete(InviteUtil.Invite invite, JDA jda)
invite
- The Invite
to delete.jda
- The account to use to delete the provided invite.PermissionException
- Thrown if the account connected to the provided JDA object does not have permission
to delete the invite.public static void delete(java.lang.String code, JDA jda)
code
- The invite code or url specifying the discord invite to delete.jda
- The account to use to delete the provided invite.PermissionException
- Thrown if the account connected to the provided JDA object does not have permission
to delete the invite.java.lang.IllegalArgumentException
- Thrown if the provided invite code/url was an invalid Invite.public static java.util.List<InviteUtil.AdvancedInvite> getInvites(Guild guildObj)
guildObj
- The Guild whose invites are being retrieved.Invites
.public static java.util.List<InviteUtil.AdvancedInvite> getInvites(Channel channelObj)
channelObj
- The Guild whose invites are being retrieved.Invites
.