Class ChannelAction
- java.lang.Object
-
- net.dv8tion.jda.core.requests.RestAction<T>
-
- net.dv8tion.jda.core.requests.restaction.AuditableRestAction<Channel>
-
- net.dv8tion.jda.core.requests.restaction.ChannelAction
-
public class ChannelAction extends AuditableRestAction<Channel>
Extension ofRestAction
specifically designed to create aChannel
. This extension allows setting properties before executing the action.- Since:
- 3.0
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class net.dv8tion.jda.core.requests.restaction.AuditableRestAction
AuditableRestAction.EmptyRestAction<T>
-
-
Field Summary
-
Fields inherited from class net.dv8tion.jda.core.requests.RestAction
DEFAULT_FAILURE, DEFAULT_SUCCESS, LOG
-
-
Constructor Summary
Constructors Constructor Description ChannelAction(net.dv8tion.jda.core.requests.Route.CompiledRoute route, java.lang.String name, Guild guild, ChannelType type)
Creates a new ChannelAction instance
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ChannelAction
addPermissionOverride(IPermissionHolder target, long allow, long deny)
Adds a new Role or MemberPermissionOverride
for the new Channel.ChannelAction
addPermissionOverride(IPermissionHolder target, java.util.Collection<Permission> allow, java.util.Collection<Permission> deny)
Adds a new Role or MemberPermissionOverride
for the new Channel.ChannelAction
setBitrate(java.lang.Integer bitrate)
Sets the bitrate for the new VoiceChannelChannelAction
setCheck(java.util.function.BooleanSupplier checks)
Sets the last-second checks before finally executing the http request in the queue.ChannelAction
setName(java.lang.String name)
Sets the name for the new ChannelChannelAction
setNSFW(boolean nsfw)
Sets the NSFW flag for the new TextChannelChannelAction
setParent(Category category)
Sets theCategory
for the new ChannelChannelAction
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
setTopic(java.lang.String topic)
Sets the topic for the new TextChannelChannelAction
setUserlimit(java.lang.Integer userlimit)
Sets the userlimit for the new VoiceChannel-
Methods inherited from class net.dv8tion.jda.core.requests.restaction.AuditableRestAction
reason
-
Methods inherited from class net.dv8tion.jda.core.requests.RestAction
complete, complete, completeAfter, getJDA, isPassContext, queue, queue, queue, queueAfter, queueAfter, queueAfter, queueAfter, queueAfter, queueAfter, setPassContext, submit, submit, submitAfter, submitAfter
-
-
-
-
Constructor Detail
-
ChannelAction
public ChannelAction(net.dv8tion.jda.core.requests.Route.CompiledRoute route, java.lang.String name, Guild guild, ChannelType type)
Creates a new ChannelAction instance
-
-
Method Detail
-
setCheck
public ChannelAction setCheck(java.util.function.BooleanSupplier checks)
Description copied from class:RestAction
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.- Overrides:
setCheck
in classAuditableRestAction<Channel>
- Parameters:
checks
- The checks to run before executing the request, ornull
to run no checks- Returns:
- The current RestAction for chaining convenience
-
setName
@CheckReturnValue public ChannelAction setName(java.lang.String name)
Sets the name for the new Channel- Parameters:
name
- The not-null name for the new Channel (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
@CheckReturnValue public ChannelAction setParent(Category category)
Sets theCategory
for the new Channel- Parameters:
category
- The parent for the new Channel- 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
-
setTopic
@CheckReturnValue public ChannelAction setTopic(java.lang.String topic)
Sets the topic for the new TextChannel- Parameters:
topic
- The topic for the new Channel (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
@CheckReturnValue public ChannelAction setNSFW(boolean nsfw)
Sets the NSFW flag for the new TextChannel- Parameters:
nsfw
- The NSFW flag for the new Channel- Returns:
- The current ChannelAction, for chaining convenience
- Throws:
java.lang.UnsupportedOperationException
- If this ChannelAction is not for a TextChannel
-
setSlowmode
@CheckReturnValue public ChannelAction 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:
java.lang.IllegalArgumentException
- If theslowmode
is greater than 120, or less than 0
-
addPermissionOverride
@CheckReturnValue public ChannelAction addPermissionOverride(IPermissionHolder target, java.util.Collection<Permission> allow, java.util.Collection<Permission> deny)
Adds a new Role or MemberPermissionOverride
for the new Channel.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:
java.lang.IllegalArgumentException
- If the specified target is null or not within the same guild.- See Also:
EnumSet
-
addPermissionOverride
@CheckReturnValue public ChannelAction addPermissionOverride(IPermissionHolder target, long allow, long deny)
Adds a new Role or MemberPermissionOverride
for the new Channel.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:
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.core.Permission...)
-
setBitrate
@CheckReturnValue public ChannelAction setBitrate(java.lang.Integer bitrate)
Sets the bitrate for the new VoiceChannel- Parameters:
bitrate
- The bitrate for the new Channel (min8000
; max96000
/128000
(forVIP Guilds
)) or null to use default (64000
)- 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 than 128000
-
setUserlimit
@CheckReturnValue public ChannelAction setUserlimit(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
-
-