Interface ChannelAction<T extends GuildChannel>
- Type Parameters:
T- The type of channel to create
- All Superinterfaces:
AuditableRestAction<T>,RestAction<T>
RestAction specifically
designed to create a GuildChannel.
This extension allows setting properties before executing the action.-
Method Summary
Modifier and TypeMethodDescriptionaddMemberPermissionOverride(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.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.Removes all currently configured permission overridesdeadline(long timestamp) Similar toRestAction.timeout(long, TimeUnit)but schedules a deadline at which the request has to be completed.getGuild()The guild to create thisGuildChannelingetType()TheChannelTypefor the resulting channelremovePermissionOverride(long id) Removes any existing override with the provided id.default ChannelAction<T>Removes any existing override with the provided id.default ChannelAction<T>Removes any existing override with the provided role/member.setBitrate(Integer bitrate) Sets the bitrate for the new VoiceChannelsetCheck(BooleanSupplier checks) Sets the last-second checks before finally executing the http request in the queue.Sets the name for the new GuildChannelsetNSFW(boolean nsfw) Sets the NSFW flag for the new TextChannelSets theCategoryfor the new GuildChannel.setPosition(Integer position) Sets the position where the new Channel should be inserted into.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.Sets the topic for the new TextChannelsetType(ChannelType type) Converts the channel to a differentChannelType.setUserlimit(Integer userlimit) Sets the userlimit for the new VoiceChannelSyncs the permission overrides of the channel with the category.Timeout for this RestAction instance.Methods inherited from interface net.dv8tion.jda.api.requests.restaction.AuditableRestAction
reasonMethods 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, queue, queue, queue, queueAfter, queueAfter, queueAfter, queueAfter, queueAfter, queueAfter, submit, submit, submitAfter, submitAfter, zip
-
Method Details
-
setCheck
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
- See Also:
-
timeout
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:
-
deadline
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:
-
getGuild
The guild to create thisGuildChannelin- Returns:
- The guild
-
getType
TheChannelTypefor the resulting channel- Returns:
- The channel type
-
setName
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
-
setType
Converts the channel to a differentChannelType.
This can only be done in the follow situations:Current Channel Type New Channel Type ChannelType.NEWS-> ChannelType.TEXTChannelType.TEXT-> ChannelType.NEWS- Parameters:
type- The not-nullChannelTypeof the new channel- Returns:
- The current ChannelAction, for chaining convenience
- Throws:
IllegalArgumentException- IfchannelTypeis notChannelType.TEXTorChannelType.NEWSUnsupportedOperationException- If this ChannelAction is not for aTextChannelorNewsChannelIllegalStateException- IfchannelTypeisChannelType.NEWSand the guild doesn't have theNEWSfeature inGuild.getFeatures().
-
setParent
Sets theCategoryfor the new GuildChannel. You can usesyncPermissionOverrides()to sync the channel with the category.- 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- See Also:
-
setPosition
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
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
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
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.If setting permission overwrites, only permissions your bot has in the guild can be allowed/denied.
Example:
Role role = guild.getPublicRole(); EnumSet<Permission> allow = EnumSet.of(Permission.VIEW_CHANNEL); EnumSet<Permission> deny = EnumSet.of(Permission.MESSAGE_SEND); 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:
InsufficientPermissionException- If any permission is set in allow/deny that the currently logged in account is missing, unlessPermission.MANAGE_PERMISSIONSorPermission.MANAGE_ROLESis granted to it within the context of the parent category.IllegalArgumentException- If the specified target is null or not within the same guild.- See Also:
-
addPermissionOverride
@Nonnull @CheckReturnValue default ChannelAction<T> addPermissionOverride(@Nonnull IPermissionHolder target, long allow, long deny) Adds a new Role or MemberPermissionOverridefor the new GuildChannel.If setting permission overwrites, only permissions your bot has in the guild can be allowed/denied.
Example:
Role role = guild.getPublicRole(); long allow = Permission.VIEW_CHANNEL.getRawValue(); long deny = Permission.MESSAGE_SEND.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:
InsufficientPermissionException- If any permission is set in allow/deny that the currently logged in account is missing, unlessPermission.MANAGE_PERMISSIONSorPermission.MANAGE_ROLESis granted to it within the context of the parent category.IllegalArgumentException-- If the specified target is null or not within the same guild.
- If one of the provided Permission values is invalid
- See Also:
-
addMemberPermissionOverride
@Nonnull @CheckReturnValue default ChannelAction<T> addMemberPermissionOverride(long memberId, @Nullable Collection<Permission> allow, @Nullable Collection<Permission> deny) Adds a new MemberPermissionOverridefor the new GuildChannel.If setting permission overwrites, only permissions your bot has in the guild can be allowed/denied.
Example:
long userId = user.getIdLong(); EnumSet<Permission> allow = EnumSet.of(Permission.VIEW_CHANNEL); EnumSet<Permission> deny = EnumSet.of(Permission.MESSAGE_SEND); 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
- Throws:
InsufficientPermissionException- If any permission is set in allow/deny that the currently logged in account is missing, unlessPermission.MANAGE_PERMISSIONSorPermission.MANAGE_ROLESis granted to it within the context of the parent category.- See Also:
-
addRolePermissionOverride
@Nonnull @CheckReturnValue default ChannelAction<T> addRolePermissionOverride(long roleId, @Nullable Collection<Permission> allow, @Nullable Collection<Permission> deny) Adds a new RolePermissionOverridefor the new GuildChannel.If setting permission overwrites, only permissions your bot has in the guild can be allowed/denied.
Example:
long roleId = role.getIdLong(); EnumSet<Permission> allow = EnumSet.of(Permission.VIEW_CHANNEL); EnumSet<Permission> deny = EnumSet.of(Permission.MESSAGE_SEND); 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
- Throws:
InsufficientPermissionException- If any permission is set in allow/deny that the currently logged in account is missing, unlessPermission.MANAGE_PERMISSIONSorPermission.MANAGE_ROLESis granted to it within the context of the parent category.- See Also:
-
addMemberPermissionOverride
@Nonnull @CheckReturnValue ChannelAction<T> addMemberPermissionOverride(long memberId, long allow, long deny) Adds a new MemberPermissionOverridefor the new GuildChannel.If setting permission overwrites, only permissions your bot has in the guild can be allowed/denied.
Example:
long userId = user.getIdLong(); long allow = Permission.VIEW_CHANNEL.getRawValue(); long deny = Permission.MESSAGE_SEND.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 invalidInsufficientPermissionException- If any permission is set in allow/deny that the currently logged in account is missing, unlessPermission.MANAGE_PERMISSIONSorPermission.MANAGE_ROLESis granted to it within the context of the parent category.- See Also:
-
addRolePermissionOverride
@Nonnull @CheckReturnValue ChannelAction<T> addRolePermissionOverride(long roleId, long allow, long deny) Adds a new RolePermissionOverridefor the new GuildChannel.If setting permission overwrites, only permissions your bot has in the guild can be allowed/denied.
Example:
long roleId = role.getIdLong(); long allow = Permission.VIEW_CHANNEL.getRawValue(); long deny = Permission.MESSAGE_SEND.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 invalidInsufficientPermissionException- If any permission is set in allow/deny that the currently logged in account is missing, unlessPermission.MANAGE_PERMISSIONSorPermission.MANAGE_ROLESis granted to it within the context of the parent category.- See Also:
-
removePermissionOverride
Removes any existing override with the provided id.
If no override with the provided id exists, this method does nothing.- Parameters:
id- The member or role id of the override- Returns:
- The current ChannelAction, for chaining convenience
-
removePermissionOverride
Removes any existing override with the provided id.
If no override with the provided id exists, this method does nothing.- Parameters:
id- The member or role id of the override- Returns:
- The current ChannelAction, for chaining convenience
- Throws:
IllegalArgumentException- If the provided string is not a valid snowflake or null
-
removePermissionOverride
@Nonnull @CheckReturnValue default ChannelAction<T> removePermissionOverride(@Nonnull IPermissionHolder holder) Removes any existing override with the provided role/member.
If no override for the provided role/member exists, this method does nothing.- Parameters:
holder- The member or role of the override- Returns:
- The current ChannelAction, for chaining convenience
- Throws:
IllegalArgumentException- If the provided permission holder is null
-
clearPermissionOverrides
Removes all currently configured permission overrides- Returns:
- The current ChannelAction, for chaining convenience
-
syncPermissionOverrides
Syncs the permission overrides of the channel with the category.If setting permission overwrites, only permissions your bot has in the guild can be allowed/denied. In order to properly sync permissions the currently logged in account must have all allowed/denied permissions or
Permission.MANAGE_ROLESin the parent category.- Returns:
- The current ChannelAction, for chaining convenience
- Throws:
IllegalArgumentException- If no parent has been configured. You have to usesetParent(Category)before calling this method.
-
setBitrate
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
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
-