Interface ChannelAction<T extends GuildChannel>
- Type Parameters:
T
- The type of channel to create
- All Superinterfaces:
AuditableRestAction<T>
,FluentAuditableRestAction<T,
,ChannelAction<T>> RestAction<T>
RestAction
specifically
designed to create a GuildChannel
.
This extension allows setting properties before executing the action.- Since:
- 3.0
- See Also:
-
Field Summary
Fields inherited from interface net.dv8tion.jda.api.requests.restaction.AuditableRestAction
MAX_REASON_LENGTH
-
Method Summary
Modifier and TypeMethodDescriptionaddMemberPermissionOverride
(long memberId, long allow, long deny) Adds a new MemberPermissionOverride
for the new GuildChannel.default ChannelAction
<T> addMemberPermissionOverride
(long memberId, Collection<Permission> allow, 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, Collection<Permission> allow, Collection<Permission> deny) Adds a new Role or MemberPermissionOverride
for the new GuildChannel.addRolePermissionOverride
(long roleId, long allow, long deny) Adds a new RolePermissionOverride
for the new GuildChannel.default ChannelAction
<T> addRolePermissionOverride
(long roleId, Collection<Permission> allow, Collection<Permission> deny) Adds a new RolePermissionOverride
for the new GuildChannel.Removes all currently configured permission overridesgetGuild()
The guild to create thisGuildChannel
ingetType()
TheChannelType
for 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.setAvailableTags
(List<? extends BaseForumTag> tags) Sets the available tags of the channel.setBitrate
(Integer bitrate) Sets the bitrate for the new VoiceChannelsetDefaultLayout
(ForumChannel.Layout layout) Sets the default layout of the newForumChannel
.setDefaultReaction
(Emoji emoji) Sets the default reaction emoji of the channel.setDefaultSortOrder
(IPostContainer.SortOrder sortOrder) Sets the default sort order of the channel.setDefaultThreadSlowmode
(int slowmode) Sets the slowmode value, which limits the amount of time that individual users must wait between sending messages in the new channel.Sets the name for the new GuildChannelsetNSFW
(boolean nsfw) Sets the NSFW flag for the channelSets theCategory
for the new GuildChannel.setPosition
(Integer position) Sets the position where the new Channel should be inserted into.Sets the voice region for the new AudioChannelsetSlowmode
(int slowmode) Sets the slowmode value, which limits the amount of time that individual users must wait between sending messages in the new channel.Sets the topic for the channelsetUserlimit
(Integer userlimit) Sets the userlimit for the newAudioChannel
.Syncs the permission overrides of the channel with the category.Methods inherited from interface net.dv8tion.jda.api.requests.restaction.FluentAuditableRestAction
addCheck, deadline, reason, setCheck, timeout
Methods inherited from interface net.dv8tion.jda.api.requests.RestAction
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
-
getGuild
The guild to create thisGuildChannel
in- Returns:
- The guild
-
getType
TheChannelType
for 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 characters long)- Returns:
- The current ChannelAction, for chaining convenience
- Throws:
IllegalArgumentException
- If the provided name is null or not between 1-100 characters long
-
setParent
Sets theCategory
for the new GuildChannel.You can use
syncPermissionOverrides()
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 isnull
or 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 channel- Parameters:
topic
- The topic for the new GuildChannel- Returns:
- The current ChannelAction, for chaining convenience
- Throws:
UnsupportedOperationException
- If this ChannelAction is not for a TextChannelIllegalArgumentException
- If the provided topic is greater than 1024 in length. ForIPostContainers
, this limit is 4096 instead.
-
setNSFW
Sets the NSFW flag for the channel- 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 channel. 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:
UnsupportedOperationException
- If this ChannelAction is not for aISlowmodeChannel
IllegalArgumentException
- If theslowmode
is greater thanISlowmodeChannel.MAX_SLOWMODE
, or less than 0
-
setDefaultThreadSlowmode
Sets the slowmode value, which limits the amount of time that individual users must wait between sending messages in the new channel. This is measured in seconds.
This is applied to newly created threads by default.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:
UnsupportedOperationException
- If this ChannelAction is not for aIThreadContainer
IllegalArgumentException
- If theslowmode
is greater thanISlowmodeChannel.MAX_SLOWMODE
, or less than 0
-
setDefaultReaction
Sets the default reaction emoji of the channel.
This does not support custom emoji from other guilds.- Parameters:
emoji
- The new default reaction emoji, or null to unset.- Returns:
- The current ChannelAction, for chaining convenience
- See Also:
-
setDefaultLayout
Sets the default layout of the newForumChannel
.- Parameters:
layout
- The new default layout.- Returns:
- The current ChannelAction, for chaining convenience
- Throws:
IllegalArgumentException
- If null orUNKNOWN
is provided- See Also:
-
setDefaultSortOrder
@Nonnull @CheckReturnValue ChannelAction<T> setDefaultSortOrder(@Nonnull IPostContainer.SortOrder sortOrder) Sets the default sort order of the channel.- Parameters:
sortOrder
- The new default sort order.- Returns:
- The current ChannelAction, for chaining convenience
- Throws:
IllegalArgumentException
- If null orUNKNOWN
is provided- See Also:
-
setAvailableTags
@Nonnull @CheckReturnValue ChannelAction<T> setAvailableTags(@Nonnull List<? extends BaseForumTag> tags) Sets the available tags of the channel.
Tags will be ordered based on the provided list order.You can use
ForumTagData
to create new tags.- Parameters:
tags
- The new available tags in the desired order.- Returns:
- The current ChannelAction, for chaining convenience
- Throws:
IllegalArgumentException
- If the provided list is null or contains null elements- See Also:
-
addPermissionOverride
@Nonnull @CheckReturnValue default ChannelAction<T> addPermissionOverride(@Nonnull IPermissionHolder target, @Nullable Collection<Permission> allow, @Nullable 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.VIEW_CHANNEL); EnumSet<Permission> deny = EnumSet.of(Permission.MESSAGE_SEND); 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.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 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.VIEW_CHANNEL.getRawValue(); long deny = Permission.MESSAGE_SEND.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.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 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.VIEW_CHANNEL); EnumSet<Permission> deny = EnumSet.of(Permission.MESSAGE_SEND); 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:
-
addRolePermissionOverride
@Nonnull @CheckReturnValue default ChannelAction<T> addRolePermissionOverride(long roleId, @Nullable Collection<Permission> allow, @Nullable 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.VIEW_CHANNEL); EnumSet<Permission> deny = EnumSet.of(Permission.MESSAGE_SEND); 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:
-
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.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 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:
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:
-
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.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 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:
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:
-
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_ROLES
in 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()
) ornull
to 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 newAudioChannel
.
The limit maximum varies by type.- Parameters:
userlimit
- The userlimit for the new AudioChannel ornull
/0
to use no limit- Returns:
- The current ChannelAction, for chaining convenience
- Throws:
UnsupportedOperationException
- If this ChannelAction is not for a AudioChannelIllegalArgumentException
- If the provided userlimit is negative or above the permitted limit
-
setRegion
Sets the voice region for the new AudioChannel- Parameters:
region
- The region for the new AudioChannel, ornull
to set toRegion.AUTOMATIC
- Returns:
- The current ChannelAction, for chaining convenience
- Throws:
UnsupportedOperationException
- If this ChannelAction is not for an AudioChannel
-