Interface ChannelAction<T extends GuildChannel>
-
- Type Parameters:
T- The type of channel to create
- All Superinterfaces:
AuditableRestAction<T>,RestAction<T>
public interface ChannelAction<T extends GuildChannel> extends AuditableRestAction<T>
Extension ofRestActionspecifically designed to create aGuildChannel. This extension allows setting properties before executing the action.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description ChannelAction<T>addMemberPermissionOverride(long memberId, long allow, long deny)Adds a new MemberPermissionOverridefor the new GuildChannel.default ChannelAction<T>addMemberPermissionOverride(long memberId, Collection<Permission> allow, Collection<Permission> deny)Adds a new MemberPermissionOverridefor the new GuildChannel.default ChannelAction<T>addPermissionOverride(IPermissionHolder target, long allow, long deny)Adds a new Role or MemberPermissionOverridefor the new GuildChannel.default ChannelAction<T>addPermissionOverride(IPermissionHolder target, Collection<Permission> allow, Collection<Permission> deny)Adds a new Role or MemberPermissionOverridefor the new GuildChannel.ChannelAction<T>addRolePermissionOverride(long roleId, long allow, long deny)Adds a new RolePermissionOverridefor the new GuildChannel.default ChannelAction<T>addRolePermissionOverride(long roleId, Collection<Permission> allow, Collection<Permission> deny)Adds a new RolePermissionOverridefor the new GuildChannel.ChannelAction<T>deadline(long timestamp)Similar toRestAction.timeout(long, TimeUnit)but schedules a deadline at which the request has to be completed.GuildgetGuild()The guild to create thisGuildChannelinChannelTypegetType()TheChannelTypefor the resulting channelChannelAction<T>setBitrate(Integer bitrate)Sets the bitrate for the new VoiceChannelChannelAction<T>setCheck(BooleanSupplier checks)Sets the last-second checks before finally executing the http request in the queue.ChannelAction<T>setName(String name)Sets the name for the new GuildChannelChannelAction<T>setNSFW(boolean nsfw)Sets the NSFW flag for the new TextChannelChannelAction<T>setParent(Category category)Sets theCategoryfor the new GuildChannelChannelAction<T>setPosition(Integer position)Sets the position where the new Channel should be inserted into.ChannelAction<T>setSlowmode(int slowmode)Sets the slowmode value, which limits the amount of time that individual users must wait between sending messages in the new TextChannel.ChannelAction<T>setTopic(String topic)Sets the topic for the new TextChannelChannelAction<T>setUserlimit(Integer userlimit)Sets the userlimit for the new VoiceChannelChannelAction<T>timeout(long timeout, TimeUnit unit)Timeout for this RestAction instance.-
Methods inherited from interface net.dv8tion.jda.api.requests.restaction.AuditableRestAction
reason
-
Methods inherited from interface net.dv8tion.jda.api.requests.RestAction
complete, complete, completeAfter, delay, delay, delay, delay, flatMap, flatMap, getJDA, map, queue, queue, queue, queueAfter, queueAfter, queueAfter, queueAfter, queueAfter, queueAfter, submit, submit, submitAfter, submitAfter
-
-
-
-
Method Detail
-
setCheck
@Nonnull ChannelAction<T> setCheck(@Nullable BooleanSupplier checks)
Description copied from interface:AuditableRestActionSets the last-second checks before finally executing the http request in the queue.
If the provided supplier evaluates tofalseor 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:
setCheckin interfaceAuditableRestAction<T extends GuildChannel>- Specified by:
setCheckin interfaceRestAction<T extends GuildChannel>- Parameters:
checks- The checks to run before executing the request, ornullto run no checks- Returns:
- The current RestAction for chaining convenience
-
timeout
@Nonnull ChannelAction<T> timeout(long timeout, @Nonnull TimeUnit unit)
Description copied from interface:AuditableRestActionTimeout 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:
timeoutin interfaceAuditableRestAction<T extends GuildChannel>- Specified by:
timeoutin interfaceRestAction<T extends GuildChannel>- Parameters:
timeout- The timeout to useunit-Unitfor the timeout value- Returns:
- The same RestAction instance with the applied timeout
- See Also:
RestAction.setDefaultTimeout(long, TimeUnit)
-
deadline
@Nonnull ChannelAction<T> deadline(long timestamp)
Description copied from interface:AuditableRestActionSimilar 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:
deadlinein interfaceAuditableRestAction<T extends GuildChannel>- Specified by:
deadlinein interfaceRestAction<T extends GuildChannel>- Parameters:
timestamp- Millisecond timestamp at which the request will timeout- Returns:
- The same RestAction with the applied deadline
- See Also:
RestAction.timeout(long, TimeUnit),RestAction.setDefaultTimeout(long, TimeUnit)
-
getGuild
@Nonnull Guild getGuild()
The guild to create thisGuildChannelin- Returns:
- The guild
-
getType
@Nonnull ChannelType getType()
TheChannelTypefor the resulting channel- Returns:
- The channel type
-
setName
@Nonnull @CheckReturnValue ChannelAction<T> setName(@Nonnull String name)
Sets the name for the new GuildChannel- Parameters:
name- The not-null name for the new GuildChannel (1-100 chars long)- Returns:
- The current ChannelAction, for chaining convenience
- Throws:
IllegalArgumentException- If the provided name is null or not between 1-100 chars long
-
setParent
@Nonnull @CheckReturnValue ChannelAction<T> setParent(@Nullable Category category)
Sets theCategoryfor the new GuildChannel- Parameters:
category- The parent for the new GuildChannel- Returns:
- The current ChannelAction, for chaining convenience
- Throws:
UnsupportedOperationException- If this ChannelAction is for a CategoryIllegalArgumentException- If the provided category isnullor not from this Guild
-
setPosition
@Nonnull @CheckReturnValue ChannelAction<T> setPosition(@Nullable Integer position)
Sets the position where the new Channel should be inserted into. This refers to the raw position value, not the computed (relative) position.By default (or by providing this method with
null), the position will automatically be computed based on the other Channels (inserted last in its respective group).Note: This does not shift the position values of existing Channels if the values collide.
As a reminder: The ordering of Channels is determined first by its Category's position, then by its raw position value and finally by its id (younger Channels are below older ones)- Parameters:
position- The raw position value that should be used for the new Channel- Returns:
- The current ChannelAction, for chaining convenience
- Throws:
IllegalArgumentException- If the provided position value is<0
-
setTopic
@Nonnull @CheckReturnValue ChannelAction<T> setTopic(@Nullable String topic)
Sets the topic for the new TextChannel- Parameters:
topic- The topic for the new GuildChannel (max 1024 chars)- Returns:
- The current ChannelAction, for chaining convenience
- Throws:
UnsupportedOperationException- If this ChannelAction is not for a TextChannelIllegalArgumentException- If the provided topic is longer than 1024 chars
-
setNSFW
@Nonnull @CheckReturnValue ChannelAction<T> setNSFW(boolean nsfw)
Sets the NSFW flag for the new TextChannel- Parameters:
nsfw- The NSFW flag for the new GuildChannel- Returns:
- The current ChannelAction, for chaining convenience
- Throws:
UnsupportedOperationException- If this ChannelAction is not for a TextChannel
-
setSlowmode
@Nonnull @CheckReturnValue ChannelAction<T> setSlowmode(int slowmode)
Sets the slowmode value, which limits the amount of time that individual users must wait between sending messages in the new TextChannel. This is measured in seconds.Note: Bots are unaffected by this.
HavingMESSAGE_MANAGEorMANAGE_CHANNELpermission also grants immunity to slowmode.- Parameters:
slowmode- The number of seconds required to wait between sending messages in the channel.- Returns:
- The current ChannelAction, for chaining convenience
- Throws:
UnsupportedOperationException- If this ChannelAction is not for a TextChannelIllegalArgumentException- If theslowmodeis greater thanTextChannel.MAX_SLOWMODE, or less than 0
-
addPermissionOverride
@Nonnull @CheckReturnValue default ChannelAction<T> addPermissionOverride(@Nonnull IPermissionHolder target, @Nullable Collection<Permission> allow, @Nullable Collection<Permission> deny)
Adds a new Role or MemberPermissionOverridefor the new GuildChannel.Example:
Role role = guild.getPublicRole(); EnumSet<Permission> allow = EnumSet.of(Permission.MESSAGE_READ); EnumSet<Permission> deny = EnumSet.of(Permission.MESSAGE_WRITE); channelAction.addPermissionOverride(role, allow, deny);- Parameters:
target- The not-nullRoleorMemberfor the overrideallow- The grantedPermissionsfor the override or nulldeny- The deniedPermissionsfor the override or null- Returns:
- The current ChannelAction, for chaining convenience
- Throws:
IllegalArgumentException- If the specified target is null or not within the same guild.- See Also:
EnumSet
-
addPermissionOverride
@Nonnull @CheckReturnValue default ChannelAction<T> addPermissionOverride(@Nonnull IPermissionHolder target, long allow, long deny)
Adds a new Role or MemberPermissionOverridefor the new GuildChannel.Example:
Role role = guild.getPublicRole(); long allow = Permission.MESSAGE_READ.getRawValue(); long deny = Permission.MESSAGE_WRITE.getRawValue() | Permission.MESSAGE_ADD_REACTION.getRawValue(); channelAction.addPermissionOverride(role, allow, deny);- Parameters:
target- The not-nullRoleorMemberfor the overrideallow- The grantedPermissionsfor the override UsePermission.getRawValue()to retrieve these Permissions.deny- The deniedPermissionsfor the override UsePermission.getRawValue()to retrieve these Permissions.- Returns:
- The current ChannelAction, for chaining convenience
- Throws:
IllegalArgumentException-- If the specified target is null or not within the same guild.
- If one of the provided Permission values is invalid
- See Also:
Permission.getRawValue(),Permission.getRaw(java.util.Collection),Permission.getRaw(net.dv8tion.jda.api.Permission...)
-
addMemberPermissionOverride
@Nonnull @CheckReturnValue default ChannelAction<T> addMemberPermissionOverride(long memberId, @Nullable Collection<Permission> allow, @Nullable Collection<Permission> deny)
Adds a new MemberPermissionOverridefor the new GuildChannel.Example:
long userId = user.getIdLong(); EnumSet<Permission> allow = EnumSet.of(Permission.MESSAGE_READ); EnumSet<Permission> deny = EnumSet.of(Permission.MESSAGE_WRITE); channelAction.addMemberPermissionOverride(userId, allow, deny);- Parameters:
memberId- The id for the memberallow- The grantedPermissionsfor the override or nulldeny- The deniedPermissionsfor the override or null- Returns:
- The current ChannelAction, for chaining convenience
- See Also:
EnumSet
-
addRolePermissionOverride
@Nonnull @CheckReturnValue default ChannelAction<T> addRolePermissionOverride(long roleId, @Nullable Collection<Permission> allow, @Nullable Collection<Permission> deny)
Adds a new RolePermissionOverridefor the new GuildChannel.Example:
long roleId = role.getIdLong(); EnumSet<Permission> allow = EnumSet.of(Permission.MESSAGE_READ); EnumSet<Permission> deny = EnumSet.of(Permission.MESSAGE_WRITE); channelAction.addRolePermissionOverride(roleId, allow, deny);- Parameters:
roleId- The id for the roleallow- The grantedPermissionsfor the override or nulldeny- The deniedPermissionsfor the override or null- Returns:
- The current ChannelAction, for chaining convenience
- See Also:
EnumSet
-
addMemberPermissionOverride
@Nonnull @CheckReturnValue ChannelAction<T> addMemberPermissionOverride(long memberId, long allow, long deny)
Adds a new MemberPermissionOverridefor the new GuildChannel.Example:
long userId = user.getIdLong(); long allow = Permission.MESSAGE_READ.getRawValue(); long deny = Permission.MESSAGE_WRITE.getRawValue() | Permission.MESSAGE_ADD_REACTION.getRawValue(); channelAction.addMemberPermissionOverride(userId, allow, deny);- Parameters:
memberId- The id for the memberallow- The grantedPermissionsfor the override UsePermission.getRawValue()to retrieve these Permissions.deny- The deniedPermissionsfor the override UsePermission.getRawValue()to retrieve these Permissions.- Returns:
- The current ChannelAction, for chaining convenience
- Throws:
IllegalArgumentException- If one of the provided Permission values is invalid- See Also:
Permission.getRawValue(),Permission.getRaw(java.util.Collection),Permission.getRaw(net.dv8tion.jda.api.Permission...)
-
addRolePermissionOverride
@Nonnull @CheckReturnValue ChannelAction<T> addRolePermissionOverride(long roleId, long allow, long deny)
Adds a new RolePermissionOverridefor the new GuildChannel.Example:
long roleId = role.getIdLong(); long allow = Permission.MESSAGE_READ.getRawValue(); long deny = Permission.MESSAGE_WRITE.getRawValue() | Permission.MESSAGE_ADD_REACTION.getRawValue(); channelAction.addMemberPermissionOverride(roleId, allow, deny);- Parameters:
roleId- The id for the roleallow- The grantedPermissionsfor the override UsePermission.getRawValue()to retrieve these Permissions.deny- The deniedPermissionsfor the override UsePermission.getRawValue()to retrieve these Permissions.- Returns:
- The current ChannelAction, for chaining convenience
- Throws:
IllegalArgumentException- If one of the provided Permission values is invalid- See Also:
Permission.getRawValue(),Permission.getRaw(java.util.Collection),Permission.getRaw(net.dv8tion.jda.api.Permission...)
-
setBitrate
@Nonnull @CheckReturnValue ChannelAction<T> setBitrate(@Nullable Integer bitrate)
Sets the bitrate for the new VoiceChannel- Parameters:
bitrate- The bitrate for the new VoiceChannel inbps(limits 8000 <= bitrate <=Guild.getMaxBitrate()) ornullto use the default 64kbps.- Returns:
- The current ChannelAction, for chaining convenience
- Throws:
UnsupportedOperationException- If this ChannelAction is not for a VoiceChannelIllegalArgumentException- If the provided bitrate is less than 8000 or greater thanGuild.getMaxBitrate()
-
setUserlimit
@Nonnull @CheckReturnValue ChannelAction<T> setUserlimit(@Nullable Integer userlimit)
Sets the userlimit for the new VoiceChannel- Parameters:
userlimit- The userlimit for the new VoiceChannel ornull/0to use no limit,- Returns:
- The current ChannelAction, for chaining convenience
- Throws:
UnsupportedOperationException- If this ChannelAction is not for a VoiceChannelIllegalArgumentException- If the provided userlimit is negative or above99
-
-