Interface GuildAction
- All Superinterfaces:
RestAction<Void>
RestAction
extension
specifically designed to allow for the creation of Guilds
.
This is available to all account types but may undergo certain restrictions by Discord.
- Since:
- 3.4.0
- See Also:
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic class
static class
-
Method Summary
Modifier and TypeMethodDescriptionaddChannel
(GuildAction.ChannelData channel) Adds aGuildChannel
to the resulting Guild.deadline
(long timestamp) Similar toRestAction.timeout(long, TimeUnit)
but schedules a deadline at which the request has to be completed.getChannel
(int index) Gets theChannelData
of the specified index.Retrieves theRoleData
for the public role (Guild.getPublicRole()
) for the resulting Guild.getRole
(int index) Retrieves theRoleData
for the provided index.newChannel
(ChannelType type, String name) Creates a newChannelData
instance and adds it to this GuildAction.newRole()
Creates and add a newRoleData
object representing a Role for the resulting Guild.removeChannel
(int index) Removes theChannelData
at the specified index and returns the removed object.Removes the providedChannelData
from this GuildAction if present.setCheck
(BooleanSupplier checks) Sets the last-second checks before finally executing the http request in the queue.Sets theExplicitContentLevel
for the resultingGuild
Sets the name for the resultingGuild
Sets theNotificationLevel
for the resultingGuild
Sets theVerificationLevel
for the resultingGuild
Timeout for this RestAction instance.Methods inherited from interface net.dv8tion.jda.api.requests.RestAction
addCheck, and, and, complete, complete, completeAfter, delay, delay, delay, delay, flatMap, flatMap, getCheck, getJDA, map, mapToResult, onErrorFlatMap, onErrorFlatMap, onErrorMap, onErrorMap, onSuccess, queue, queue, queue, queueAfter, queueAfter, queueAfter, queueAfter, queueAfter, queueAfter, submit, submit, submitAfter, submitAfter, zip
-
Method Details
-
setCheck
Description copied from interface: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.- Specified by:
setCheck
in interfaceRestAction<Void>
- Parameters:
checks
- The checks to run before executing the request, ornull
to run no checks- Returns:
- The current RestAction for chaining convenience
- See Also:
-
timeout
Description copied from interface:RestAction
Timeout for this RestAction instance.
If the request doesn't get executed within the timeout it will fail.When a RestAction times out, it will fail with a
TimeoutException
. This is the same asdeadline(System.currentTimeMillis() + unit.toMillis(timeout))
.Example
action.timeout(10, TimeUnit.SECONDS) // 10 seconds from now .queueAfter(20, SECONDS); // request will not be executed within deadline and timeout immediately after 20 seconds
- Specified by:
timeout
in interfaceRestAction<Void>
- Parameters:
timeout
- The timeout to useunit
-Unit
for the timeout value- Returns:
- The same RestAction instance with the applied timeout
- See Also:
-
deadline
Description copied from interface:RestAction
Similar toRestAction.timeout(long, TimeUnit)
but schedules a deadline at which the request has to be completed.
If the deadline is reached, the request will fail with aTimeoutException
.This does not mean that the request will immediately timeout when the deadline is reached. JDA will check the deadline right before executing the request or within intervals in a worker thread. This only means the request will timeout if the deadline has passed.
Example
action.deadline(System.currentTimeMillis() + 10000) // 10 seconds from now .queueAfter(20, SECONDS); // request will not be executed within deadline and timeout immediately after 20 seconds
- Specified by:
deadline
in interfaceRestAction<Void>
- Parameters:
timestamp
- Millisecond timestamp at which the request will timeout- Returns:
- The same RestAction with the applied deadline
- See Also:
-
setIcon
- Parameters:
icon
- TheIcon
to use- Returns:
- The current GuildAction for chaining convenience
-
setName
Sets the name for the resultingGuild
- Parameters:
name
- The name to use- Returns:
- The current GuildAction for chaining convenience
- Throws:
IllegalArgumentException
- If the provided name isnull
, blank or not between 2-100 characters long
-
setVerificationLevel
@Nonnull @CheckReturnValue GuildAction setVerificationLevel(@Nullable Guild.VerificationLevel level) Sets theVerificationLevel
for the resultingGuild
- Parameters:
level
- TheVerificationLevel
to use- Returns:
- The current GuildAction for chaining convenience
-
setNotificationLevel
@Nonnull @CheckReturnValue GuildAction setNotificationLevel(@Nullable Guild.NotificationLevel level) Sets theNotificationLevel
for the resultingGuild
- Parameters:
level
- TheNotificationLevel
to use- Returns:
- The current GuildAction for chaining convenience
-
setExplicitContentLevel
@Nonnull @CheckReturnValue GuildAction setExplicitContentLevel(@Nullable Guild.ExplicitContentLevel level) Sets theExplicitContentLevel
for the resultingGuild
- Parameters:
level
- TheExplicitContentLevel
to use- Returns:
- The current GuildAction for chaining convenience
-
addChannel
Adds aGuildChannel
to the resulting Guild. This cannot be of typeCATEGORY
!- Parameters:
channel
- TheChannelData
to use for the construction of the GuildChannel- Returns:
- The current GuildAction for chaining convenience
- Throws:
IllegalArgumentException
- If the provided channel isnull
!
-
getChannel
Gets theChannelData
of the specified index. The index is 0 based on insertion order ofaddChannel(ChannelData)
!- Parameters:
index
- The 0 based index of the channel- Returns:
- The current GuildAction for chaining convenience
- Throws:
IndexOutOfBoundsException
- If the provided index is not in bounds
-
removeChannel
Removes theChannelData
at the specified index and returns the removed object.- Parameters:
index
- The index of the channel- Returns:
- The removed object
- Throws:
IndexOutOfBoundsException
- If the index is out of bounds
-
removeChannel
Removes the providedChannelData
from this GuildAction if present.- Parameters:
data
- The ChannelData to remove- Returns:
- The current GuildAction for chaining convenience
-
newChannel
@Nonnull @CheckReturnValue GuildAction.ChannelData newChannel(@Nonnull ChannelType type, @Nonnull String name) Creates a newChannelData
instance and adds it to this GuildAction.- Parameters:
type
- TheChannelType
of the resulting GuildChannel
This may be of typeTEXT
orVOICE
!name
- The name of the channel.- Returns:
- The new ChannelData instance
- Throws:
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
-
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
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:
IndexOutOfBoundsException
- If the provided index is out of bounds
-
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
-