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>
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.Guild
getGuild()
The guild to create thisGuildChannel
inChannelType
getType()
TheChannelType
for 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 theCategory
for 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 VoiceChannel-
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, getJDA, 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: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
-
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 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 theCategory
for 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 isnull
or 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 that only
CLIENT
type accounts are affected by slowmode, and thatBOT
accounts are immune to the restrictions.
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:
IllegalArgumentException
- If theslowmode
is greater than 21600, 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 MemberPermissionOverride
for 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-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:
IllegalArgumentException
- If the specified target is null or not within the same guild.- See Also:
EnumSet
-
addPermissionOverride
@Nonnull @CheckReturnValue ChannelAction<T> addPermissionOverride(@Nonnull IPermissionHolder target, long allow, long deny)
Adds a new Role or MemberPermissionOverride
for 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-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:
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...)
-
setBitrate
@Nonnull @CheckReturnValue ChannelAction<T> setBitrate(@Nullable Integer bitrate)
Sets the bitrate for the new VoiceChannel- Parameters:
bitrate
- The bitrate for the new GuildChannel (min8000
; max96000
/128000
(forVIP Guilds
)) or null to use default (64000
)- 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
/0
to 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
-
-