Class GuildAction
- java.lang.Object
-
- net.dv8tion.jda.core.requests.RestAction<java.lang.Void>
-
- net.dv8tion.jda.core.requests.restaction.GuildAction
-
public class GuildAction extends RestAction<java.lang.Void>
RestAction
extension specifically designed to allow for the creation ofGuilds
.
This is available to all account types but may undergo certain restrictions by Discord.- Since:
- 3.4.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
GuildAction.ChannelData
static class
GuildAction.RoleData
-
Nested classes/interfaces inherited from class net.dv8tion.jda.core.requests.RestAction
RestAction.EmptyRestAction<T>
-
-
Field Summary
-
Fields inherited from class net.dv8tion.jda.core.requests.RestAction
DEFAULT_FAILURE, DEFAULT_SUCCESS, LOG
-
-
Constructor Summary
Constructors Constructor Description GuildAction(JDA api, java.lang.String name)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description GuildAction
addChannel(GuildAction.ChannelData channel)
Adds aChannel
to the resulting Guild.GuildAction.ChannelData
getChannel(int index)
Gets theChannelData
of the specified index.GuildAction.RoleData
getPublicRole()
Retrieves theRoleData
for the public role (Guild.getPublicRole()
) for the resulting Guild.GuildAction.RoleData
getRole(int index)
Retrieves theRoleData
for the provided index.GuildAction.ChannelData
newChannel(ChannelType type, java.lang.String name)
Creates a newChannelData
instance and adds it to this GuildAction.GuildAction.RoleData
newRole()
Creates and add a newRoleData
object representing a Role for the resulting Guild.GuildAction.ChannelData
removeChannel(int index)
Removes theChannelData
at the specified index and returns the removed object.GuildAction
removeChannel(GuildAction.ChannelData data)
Removes the providedChannelData
from this GuildAction if present.GuildAction
setCheck(java.util.function.BooleanSupplier checks)
Sets the last-second checks before finally executing the http request in the queue.GuildAction
setExplicitContentLevel(Guild.ExplicitContentLevel level)
Sets theExplicitContentLevel
for the resultingGuild
GuildAction
setIcon(Icon icon)
GuildAction
setName(java.lang.String name)
Sets the name for the resultingGuild
GuildAction
setNotificationLevel(Guild.NotificationLevel level)
Sets theNotificationLevel
for the resultingGuild
GuildAction
setRegion(Region region)
GuildAction
setVerificationLevel(Guild.VerificationLevel level)
Sets theVerificationLevel
for the resultingGuild
-
Methods inherited from class net.dv8tion.jda.core.requests.RestAction
complete, complete, completeAfter, getJDA, isPassContext, queue, queue, queue, queueAfter, queueAfter, queueAfter, queueAfter, queueAfter, queueAfter, setPassContext, submit, submit, submitAfter, submitAfter
-
-
-
-
Constructor Detail
-
GuildAction
public GuildAction(JDA api, java.lang.String name)
-
-
Method Detail
-
setCheck
public GuildAction setCheck(java.util.function.BooleanSupplier checks)
Description copied from class:RestAction
Sets the last-second checks before finally executing the http request in the queue.
If the provided supplier evaluates tofalse
or throws an exception this will not be finished. When an exception is thrown from the supplier it will be provided to the failure callback.- Overrides:
setCheck
in classRestAction<java.lang.Void>
- Parameters:
checks
- The checks to run before executing the request, ornull
to run no checks- Returns:
- The current RestAction for chaining convenience
-
setRegion
@CheckReturnValue public GuildAction setRegion(Region region)
- Parameters:
region
- TheRegion
to use- Returns:
- The current GuildAction for chaining convenience
- Throws:
java.lang.IllegalArgumentException
- If the provided region is a VIP region as perRegion.isVip()
-
setIcon
@CheckReturnValue public GuildAction setIcon(Icon icon)
- Parameters:
icon
- TheIcon
to use- Returns:
- The current GuildAction for chaining convenience
-
setName
@CheckReturnValue public GuildAction setName(java.lang.String name)
Sets the name for the resultingGuild
- Parameters:
name
- The name to use- Returns:
- The current GuildAction for chaining convenience
- Throws:
java.lang.IllegalArgumentException
- If the provided name isnull
, blank or not between 2-100 characters long
-
setVerificationLevel
@CheckReturnValue public GuildAction setVerificationLevel(Guild.VerificationLevel level)
Sets theVerificationLevel
for the resultingGuild
- Parameters:
level
- TheVerificationLevel
to use- Returns:
- The current GuildAction for chaining convenience
-
setNotificationLevel
@CheckReturnValue public GuildAction setNotificationLevel(Guild.NotificationLevel level)
Sets theNotificationLevel
for the resultingGuild
- Parameters:
level
- TheNotificationLevel
to use- Returns:
- The current GuildAction for chaining convenience
-
setExplicitContentLevel
@CheckReturnValue public GuildAction setExplicitContentLevel(Guild.ExplicitContentLevel level)
Sets theExplicitContentLevel
for the resultingGuild
- Parameters:
level
- TheExplicitContentLevel
to use- Returns:
- The current GuildAction for chaining convenience
-
addChannel
@CheckReturnValue public GuildAction addChannel(GuildAction.ChannelData channel)
- Parameters:
channel
- TheChannelData
to use for the construction of the Channel- Returns:
- The current GuildAction for chaining convenience
- Throws:
java.lang.IllegalArgumentException
- If the provided channel isnull
!
-
getChannel
@CheckReturnValue public GuildAction.ChannelData getChannel(int index)
Gets theChannelData
of the specified index. The index is 0 based on insertion order ofaddChannel(GuildAction.ChannelData)
!- Parameters:
index
- The 0 based index of the channel- Returns:
- The current GuildAction for chaining convenience
- Throws:
java.lang.IndexOutOfBoundsException
- If the provided index is not in bounds
-
removeChannel
@CheckReturnValue public GuildAction.ChannelData removeChannel(int index)
Removes theChannelData
at the specified index and returns the removed object.- Parameters:
index
- The index of the channel- Returns:
- The removed object
- Throws:
java.lang.IndexOutOfBoundsException
- If the index is out of bounds
-
removeChannel
@CheckReturnValue public GuildAction removeChannel(GuildAction.ChannelData data)
Removes the providedChannelData
from this GuildAction if present.- Parameters:
data
- The ChannelData to remove- Returns:
- The current GuildAction for chaining convenience
-
newChannel
@CheckReturnValue public GuildAction.ChannelData newChannel(ChannelType type, java.lang.String name)
Creates a newChannelData
instance and adds it to this GuildAction.- Parameters:
type
- TheChannelType
of the resulting Channel
This may be of typeTEXT
orVOICE
!name
- The name of the channel. This must be alphanumeric with underscores for type TEXT- Returns:
- The new ChannelData instance
- Throws:
java.lang.IllegalArgumentException
-- If provided with an invalid ChannelType
- If the provided name is
null
or blank - If the provided name is not between 2-100 characters long
- If the type is TEXT and the provided name is not alphanumeric with underscores
-
getPublicRole
@CheckReturnValue public GuildAction.RoleData getPublicRole()
Retrieves theRoleData
for the public role (Guild.getPublicRole()
) for the resulting Guild.
The public role is also known in the official client as the@everyone
role.You can only change the permissions of the public role!
- Returns:
- RoleData of the public role
-
getRole
@CheckReturnValue public GuildAction.RoleData getRole(int index)
Retrieves theRoleData
for the provided index.
The public role is at the index 0 and all others are ordered by insertion order!- Parameters:
index
- The index of the role- Returns:
- RoleData of the provided index
- Throws:
java.lang.IndexOutOfBoundsException
- If the provided index is out of bounds
-
newRole
@CheckReturnValue public GuildAction.RoleData newRole()
Creates and add a newRoleData
object representing a Role for the resulting Guild.This can be used in
ChannelData.addPermissionOverride(...)
.
You may change any properties of thisRoleData
instance!- Returns:
- RoleData for the new Role
-
-