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 ofRestAction
specifically 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 MemberPermissionOverride
for the new GuildChannel.default ChannelAction<T>
addMemberPermissionOverride(long memberId, java.util.Collection<Permission> allow, java.util.Collection<Permission> deny)
Adds a new MemberPermissionOverride
for the new GuildChannel.default ChannelAction<T>
addPermissionOverride(IPermissionHolder target, long allow, long deny)
Adds a new Role or MemberPermissionOverride
for the new GuildChannel.default ChannelAction<T>
addPermissionOverride(IPermissionHolder target, java.util.Collection<Permission> allow, java.util.Collection<Permission> deny)
Adds a new Role or MemberPermissionOverride
for the new GuildChannel.ChannelAction<T>
addRolePermissionOverride(long roleId, long allow, long deny)
Adds a new RolePermissionOverride
for the new GuildChannel.default ChannelAction<T>
addRolePermissionOverride(long roleId, java.util.Collection<Permission> allow, java.util.Collection<Permission> deny)
Adds a new RolePermissionOverride
for the new GuildChannel.ChannelAction<T>
clearPermissionOverrides()
Removes all currently configured permission overridesChannelAction<T>
deadline(long timestamp)
Similar toRestAction.timeout(long, TimeUnit)
but schedules a deadline at which the request has to be completed.Guild
getGuild()
The guild to create thisGuildChannel
inChannelType
getType()
TheChannelType
for the resulting channelChannelAction<T>
removePermissionOverride(long id)
Removes any existing override with the provided id.default ChannelAction<T>
removePermissionOverride(java.lang.String id)
Removes any existing override with the provided id.default ChannelAction<T>
removePermissionOverride(IPermissionHolder holder)
Removes any existing override with the provided role/member.ChannelAction<T>
setBitrate(java.lang.Integer bitrate)
Sets the bitrate for the new VoiceChannelChannelAction<T>
setCheck(java.util.function.BooleanSupplier checks)
Sets the last-second checks before finally executing the http request in the queue.ChannelAction<T>
setName(java.lang.String name)
Sets the name for the new GuildChannelChannelAction<T>
setNews(boolean news)
Sets the news flag for the new TextChannel.ChannelAction<T>
setNSFW(boolean nsfw)
Sets the NSFW flag for the new TextChannelChannelAction<T>
setParent(Category category)
Sets theCategory
for the new GuildChannel.ChannelAction<T>
setPosition(java.lang.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(java.lang.String topic)
Sets the topic for the new TextChannelChannelAction<T>
setUserlimit(java.lang.Integer userlimit)
Sets the userlimit for the new VoiceChannelChannelAction<T>
syncPermissionOverrides()
Syncs the permission overrides of the channel with the category.ChannelAction<T>
timeout(long timeout, java.util.concurrent.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
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 Detail
-
setCheck
@Nonnull ChannelAction<T> setCheck(@Nullable java.util.function.BooleanSupplier checks)
Description copied from interface:AuditableRestAction
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 interfaceAuditableRestAction<T extends GuildChannel>
- Specified by:
setCheck
in interfaceRestAction<T extends GuildChannel>
- Parameters:
checks
- The checks to run before executing the request, ornull
to run no checks- Returns:
- The current RestAction for chaining convenience
- See Also:
RestAction.getCheck()
,RestAction.addCheck(BooleanSupplier)
-
timeout
@Nonnull ChannelAction<T> timeout(long timeout, @Nonnull java.util.concurrent.TimeUnit unit)
Description copied from interface:AuditableRestAction
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 interfaceAuditableRestAction<T extends GuildChannel>
- Specified by:
timeout
in interfaceRestAction<T extends GuildChannel>
- Parameters:
timeout
- The timeout to useunit
-Unit
for 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:AuditableRestAction
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 interfaceAuditableRestAction<T extends GuildChannel>
- Specified by:
deadline
in 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 thisGuildChannel
in- Returns:
- The guild
-
getType
@Nonnull ChannelType getType()
TheChannelType
for the resulting channel- Returns:
- The channel type
-
setName
@Nonnull @CheckReturnValue ChannelAction<T> setName(@Nonnull java.lang.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:
java.lang.IllegalArgumentException
- If the provided name is null or not between 1-100 chars long
-
setParent
@Nonnull @CheckReturnValue ChannelAction<T> setParent(@Nullable Category category)
Sets theCategory
for 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:
java.lang.UnsupportedOperationException
- If this ChannelAction is for a Categoryjava.lang.IllegalArgumentException
- If the provided category isnull
or not from this Guild- See Also:
syncPermissionOverrides()
-
setPosition
@Nonnull @CheckReturnValue ChannelAction<T> setPosition(@Nullable java.lang.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:
java.lang.IllegalArgumentException
- If the provided position value is<0
-
setTopic
@Nonnull @CheckReturnValue ChannelAction<T> setTopic(@Nullable java.lang.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:
java.lang.UnsupportedOperationException
- If this ChannelAction is not for a TextChanneljava.lang.IllegalArgumentException
- 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:
java.lang.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_MANAGE
orMANAGE_CHANNEL
permission 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:
java.lang.UnsupportedOperationException
- If this ChannelAction is not for a TextChanneljava.lang.IllegalArgumentException
- If theslowmode
is greater thanTextChannel.MAX_SLOWMODE
, or less than 0
-
setNews
@Nonnull @CheckReturnValue ChannelAction<T> setNews(boolean news)
Sets the news flag for the new TextChannel. Announcement-/News-Channels can be used to crosspost messages to other guilds.- Parameters:
news
- The news flag for the new GuildChannel- Returns:
- The current ChannelAction, for chaining convenience
- Throws:
java.lang.UnsupportedOperationException
- If this ChannelAction is not for a TextChanneljava.lang.IllegalStateException
- Ifnews
istrue
and the guild doesn't have the NEWS feature- Since:
- 4.2.1
- See Also:
TextChannel.isNews()
-
addPermissionOverride
@Nonnull @CheckReturnValue default ChannelAction<T> addPermissionOverride(@Nonnull IPermissionHolder target, @Nullable java.util.Collection<Permission> allow, @Nullable java.util.Collection<Permission> deny)
Adds a new Role or MemberPermissionOverride
for 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.MESSAGE_READ); EnumSet<Permission> deny = EnumSet.of(Permission.MESSAGE_WRITE); channelAction.addPermissionOverride(role, allow, deny);
- Parameters:
target
- The not-nullRole
orMember
for the overrideallow
- The grantedPermissions
for the override or nulldeny
- The deniedPermissions
for 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_PERMISSIONS
orPermission.MANAGE_ROLES
is granted to it within the context of the parent category.java.lang.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 MemberPermissionOverride
for 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.MESSAGE_READ.getRawValue(); long deny = Permission.MESSAGE_WRITE.getRawValue() | Permission.MESSAGE_ADD_REACTION.getRawValue(); channelAction.addPermissionOverride(role, allow, deny);
- Parameters:
target
- The not-nullRole
orMember
for the overrideallow
- The grantedPermissions
for the override. UsePermission.getRawValue()
to retrieve these Permissions.deny
- The deniedPermissions
for 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_PERMISSIONS
orPermission.MANAGE_ROLES
is granted to it within the context of the parent category.java.lang.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 java.util.Collection<Permission> allow, @Nullable java.util.Collection<Permission> deny)
Adds a new MemberPermissionOverride
for 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.MESSAGE_READ); EnumSet<Permission> deny = EnumSet.of(Permission.MESSAGE_WRITE); channelAction.addMemberPermissionOverride(userId, allow, deny);
- Parameters:
memberId
- The id for the memberallow
- The grantedPermissions
for the override or nulldeny
- The deniedPermissions
for 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_PERMISSIONS
orPermission.MANAGE_ROLES
is granted to it within the context of the parent category.- See Also:
EnumSet
-
addRolePermissionOverride
@Nonnull @CheckReturnValue default ChannelAction<T> addRolePermissionOverride(long roleId, @Nullable java.util.Collection<Permission> allow, @Nullable java.util.Collection<Permission> deny)
Adds a new RolePermissionOverride
for 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.MESSAGE_READ); EnumSet<Permission> deny = EnumSet.of(Permission.MESSAGE_WRITE); channelAction.addRolePermissionOverride(roleId, allow, deny);
- Parameters:
roleId
- The id for the roleallow
- The grantedPermissions
for the override or nulldeny
- The deniedPermissions
for 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_PERMISSIONS
orPermission.MANAGE_ROLES
is granted to it within the context of the parent category.- See Also:
EnumSet
-
addMemberPermissionOverride
@Nonnull @CheckReturnValue ChannelAction<T> addMemberPermissionOverride(long memberId, long allow, long deny)
Adds a new MemberPermissionOverride
for 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.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 grantedPermissions
for the override. UsePermission.getRawValue()
to retrieve these Permissions.deny
- The deniedPermissions
for the override. UsePermission.getRawValue()
to retrieve these Permissions.- Returns:
- The current ChannelAction, for chaining convenience
- Throws:
java.lang.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_PERMISSIONS
orPermission.MANAGE_ROLES
is granted to it within the context of the parent category.- 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 RolePermissionOverride
for 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.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 grantedPermissions
for the override. UsePermission.getRawValue()
to retrieve these Permissions.deny
- The deniedPermissions
for the override. UsePermission.getRawValue()
to retrieve these Permissions.- Returns:
- The current ChannelAction, for chaining convenience
- Throws:
java.lang.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_PERMISSIONS
orPermission.MANAGE_ROLES
is granted to it within the context of the parent category.- See Also:
Permission.getRawValue()
,Permission.getRaw(java.util.Collection)
,Permission.getRaw(net.dv8tion.jda.api.Permission...)
-
removePermissionOverride
@Nonnull @CheckReturnValue ChannelAction<T> removePermissionOverride(long id)
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
@Nonnull @CheckReturnValue default ChannelAction<T> removePermissionOverride(@Nonnull java.lang.String id)
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:
java.lang.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:
java.lang.IllegalArgumentException
- If the provided permission holder is null
-
clearPermissionOverrides
@Nonnull @CheckReturnValue ChannelAction<T> clearPermissionOverrides()
Removes all currently configured permission overrides- Returns:
- The current ChannelAction, for chaining convenience
-
syncPermissionOverrides
@Nonnull @CheckReturnValue ChannelAction<T> 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_ROLES
in the parent category.- Returns:
- The current ChannelAction, for chaining convenience
- Throws:
java.lang.IllegalArgumentException
- If no parent has been configured. You have to usesetParent(Category)
before calling this method.
-
setBitrate
@Nonnull @CheckReturnValue ChannelAction<T> setBitrate(@Nullable java.lang.Integer bitrate)
Sets the bitrate for the new VoiceChannel- Parameters:
bitrate
- The bitrate for the new VoiceChannel inbps
(limits 8000 <= bitrate <=Guild.getMaxBitrate()
) ornull
to use the default 64kbps.- Returns:
- The current ChannelAction, for chaining convenience
- Throws:
java.lang.UnsupportedOperationException
- If this ChannelAction is not for a VoiceChanneljava.lang.IllegalArgumentException
- If the provided bitrate is less than 8000 or greater thanGuild.getMaxBitrate()
-
setUserlimit
@Nonnull @CheckReturnValue ChannelAction<T> setUserlimit(@Nullable java.lang.Integer userlimit)
Sets the userlimit for the new VoiceChannel- Parameters:
userlimit
- The userlimit for the new VoiceChannel ornull
/0
to use no limit,- Returns:
- The current ChannelAction, for chaining convenience
- Throws:
java.lang.UnsupportedOperationException
- If this ChannelAction is not for a VoiceChanneljava.lang.IllegalArgumentException
- If the provided userlimit is negative or above99
-
-