Class ChannelManager
- java.lang.Object
-
- net.dv8tion.jda.core.requests.RestAction<T>
-
- net.dv8tion.jda.core.requests.restaction.AuditableRestAction<java.lang.Void>
-
- net.dv8tion.jda.core.managers.impl.ManagerBase
-
- net.dv8tion.jda.core.managers.ChannelManager
-
public class ChannelManager extends net.dv8tion.jda.core.managers.impl.ManagerBase
Manager providing functionality to update one or more fields for aGuild Channel
.Example
manager.setName("github-log") .setTopic("logs for github commits") .setNSFW(false) .queue(); manager.reset(ChannelManager.TOPIC | ChannelManager.NAME) .setName("nsfw-commits") .setTopic(null) .setNSFW(true) .queue();
- See Also:
Channel.getManager()
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class net.dv8tion.jda.core.requests.restaction.AuditableRestAction
AuditableRestAction.EmptyRestAction<T>
-
-
Field Summary
Fields Modifier and Type Field Description static long
BITRATE
Used to reset the bitrate fieldstatic long
NAME
Used to reset the name fieldstatic long
NSFW
Used to reset the nsfw fieldstatic long
PARENT
Used to reset the parent fieldstatic long
PERMISSION
Used to reset the permission fieldstatic long
POSITION
Used to reset the position fieldstatic long
SLOWMODE
Used to reset the rate-limit per user fieldstatic long
TOPIC
Used to reset the topic fieldstatic long
USERLIMIT
Used to reset the userlimit field-
Fields inherited from class net.dv8tion.jda.core.requests.RestAction
DEFAULT_FAILURE, DEFAULT_SUCCESS, LOG
-
-
Constructor Summary
Constructors Constructor Description ChannelManager(Channel channel)
Creates a new ChannelManager instance
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ChannelManager
clearOverridesAdded()
Clears the overrides added viaputPermissionOverride(IPermissionHolder, Collection, Collection)
.ChannelManager
clearOverridesRemoved()
Clears the overrides removed viaremovePermissionOverride(IPermissionHolder)
.Channel
getChannel()
TheChannel
that will be modified by this Manager instanceGuild
getGuild()
ChannelType
getType()
TheChannelType
ChannelManager
putPermissionOverride(IPermissionHolder permHolder, long allow, long deny)
Adds an override for the specifiedIPermissionHolder
with the provided raw bitmasks as allowed and denied permissions.ChannelManager
putPermissionOverride(IPermissionHolder permHolder, java.util.Collection<Permission> allow, java.util.Collection<Permission> deny)
Adds an override for the specifiedIPermissionHolder
with the provided permission sets as allowed and denied permissions.ChannelManager
removePermissionOverride(IPermissionHolder permHolder)
Removes thePermissionOverride
for the specifiedIPermissionHolder
.ChannelManager
reset()
Resets all fields for this manager.ChannelManager
reset(long fields)
Resets the fields specified by the provided bit-flag pattern.ChannelManager
reset(long... fields)
Resets the fields specified by the provided bit-flag patterns.ChannelManager
setBitrate(int bitrate)
Sets the bitrate of the selectedVoiceChannel
.ChannelManager
setName(java.lang.String name)
Sets the name of the selectedChannel
.ChannelManager
setNSFW(boolean nsfw)
Sets the nsfw flag of the selectedTextChannel
.ChannelManager
setParent(Category category)
Sets theParent Category
of the selectedChannel
.ChannelManager
setPosition(int position)
Sets the position of the selectedChannel
.ChannelManager
setSlowmode(int slowmode)
Sets the slowmode of the selectedTextChannel
.ChannelManager
setTopic(java.lang.String topic)
Sets the topic of the selectedTextChannel
.ChannelManager
setUserLimit(int userLimit)
Sets the user-limit of the selectedVoiceChannel
.ChannelManager
sync()
Syncs allPermissionOverrides
of this Channel with its parent (Category
).ChannelManager
sync(Channel syncSource)
Syncs allPermissionOverrides
of this Channel with the given (Channel
).-
Methods inherited from class net.dv8tion.jda.core.managers.impl.ManagerBase
complete, isPermissionChecksEnabled, queue, setPermissionChecksEnabled
-
Methods inherited from class net.dv8tion.jda.core.requests.restaction.AuditableRestAction
reason, setCheck
-
Methods inherited from class net.dv8tion.jda.core.requests.RestAction
complete, completeAfter, getJDA, isPassContext, queue, queue, queueAfter, queueAfter, queueAfter, queueAfter, queueAfter, queueAfter, setPassContext, submit, submit, submitAfter, submitAfter
-
-
-
-
Field Detail
-
NAME
public static final long NAME
Used to reset the name field- See Also:
- Constant Field Values
-
PARENT
public static final long PARENT
Used to reset the parent field- See Also:
- Constant Field Values
-
TOPIC
public static final long TOPIC
Used to reset the topic field- See Also:
- Constant Field Values
-
POSITION
public static final long POSITION
Used to reset the position field- See Also:
- Constant Field Values
-
NSFW
public static final long NSFW
Used to reset the nsfw field- See Also:
- Constant Field Values
-
USERLIMIT
public static final long USERLIMIT
Used to reset the userlimit field- See Also:
- Constant Field Values
-
BITRATE
public static final long BITRATE
Used to reset the bitrate field- See Also:
- Constant Field Values
-
PERMISSION
public static final long PERMISSION
Used to reset the permission field- See Also:
- Constant Field Values
-
SLOWMODE
public static final long SLOWMODE
Used to reset the rate-limit per user field- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ChannelManager
public ChannelManager(Channel channel)
Creates a new ChannelManager instance- Parameters:
channel
-Channel
that should be modified
EitherVoice
- orTextChannel
-
-
Method Detail
-
getType
public ChannelType getType()
TheChannelType
- Returns:
- The ChannelType
-
getChannel
public Channel getChannel()
TheChannel
that will be modified by this Manager instance- Returns:
- The
Channel
-
getGuild
public Guild getGuild()
TheGuild
this Manager'sChannel
is in.
This is logically the same as callinggetChannel().getGuild()
- Returns:
- The parent
Guild
-
reset
@CheckReturnValue public ChannelManager reset(long fields)
Resets the fields specified by the provided bit-flag pattern. You can specify a combination by using a bitwise OR concat of the flag constants.
Example:manager.reset(ChannelManager.NAME | ChannelManager.PARENT);
Flag Constants:
- Overrides:
reset
in classnet.dv8tion.jda.core.managers.impl.ManagerBase
- Parameters:
fields
- Integer value containing the flags to reset.- Returns:
- ChannelManager for chaining convenience
-
reset
@CheckReturnValue public ChannelManager reset(long... fields)
Resets the fields specified by the provided bit-flag patterns.
Example:manager.reset(ChannelManager.NAME, ChannelManager.PARENT);
Flag Constants:
- Overrides:
reset
in classnet.dv8tion.jda.core.managers.impl.ManagerBase
- Parameters:
fields
- Integer values containing the flags to reset.- Returns:
- ChannelManager for chaining convenience
-
reset
@CheckReturnValue public ChannelManager reset()
Resets all fields for this manager.- Returns:
- ChannelManager for chaining convenience
-
clearOverridesAdded
public ChannelManager clearOverridesAdded()
Clears the overrides added viaputPermissionOverride(IPermissionHolder, Collection, Collection)
.- Returns:
- ChannelManager for chaining convenience
-
clearOverridesRemoved
public ChannelManager clearOverridesRemoved()
Clears the overrides removed viaremovePermissionOverride(IPermissionHolder)
.- Returns:
- ChannelManager for chaining convenience
-
putPermissionOverride
@CheckReturnValue public ChannelManager putPermissionOverride(IPermissionHolder permHolder, long allow, long deny)
Adds an override for the specifiedIPermissionHolder
with the provided raw bitmasks as allowed and denied permissions. If the permission holder already had an override on this channel it will be updated instead.- Parameters:
permHolder
- The permission holderallow
- The bitmask to grantdeny
- The bitmask to deny- Returns:
- ChannelManager for chaining convenience
- Throws:
java.lang.IllegalArgumentException
- If the provided permission holder isnull
InsufficientPermissionException
- If the currently logged in account does not havePermission.MANAGE_PERMISSIONS
in this channel- See Also:
putPermissionOverride(IPermissionHolder, Collection, Collection)
,Permission.getRaw(Permission...)
-
putPermissionOverride
@CheckReturnValue public ChannelManager putPermissionOverride(IPermissionHolder permHolder, java.util.Collection<Permission> allow, java.util.Collection<Permission> deny)
Adds an override for the specifiedIPermissionHolder
with the provided permission sets as allowed and denied permissions. If the permission holder already had an override on this channel it will be updated instead.
Example:putPermissionOverride(guild.getSelfMember(), EnumSet.of(Permission.MESSAGE_WRITE, Permission.MESSAGE_READ), null)
- Parameters:
permHolder
- The permission holderallow
- The permissions to grant, or nulldeny
- The permissions to deny, or null- Returns:
- ChannelManager for chaining convenience
- Throws:
java.lang.IllegalArgumentException
- If the provided permission holder isnull
InsufficientPermissionException
- If the currently logged in account does not havePermission.MANAGE_PERMISSIONS
in this channel- See Also:
putPermissionOverride(IPermissionHolder, long, long)
,EnumSet
-
removePermissionOverride
@CheckReturnValue public ChannelManager removePermissionOverride(IPermissionHolder permHolder)
Removes thePermissionOverride
for the specifiedIPermissionHolder
. If no override existed for this member this does nothing.- Parameters:
permHolder
- The permission holder- Returns:
- ChannelManager for chaining convenience
- Throws:
java.lang.IllegalArgumentException
- If the provided permission holder isnull
InsufficientPermissionException
- If the currently logged in account does not havePermission.MANAGE_PERMISSIONS
in this channel
-
sync
@CheckReturnValue public ChannelManager sync()
Syncs allPermissionOverrides
of this Channel with its parent (Category
).After this operation, all
PermissionOverrides
will be exactly the same as the ones from the parent.
That means that all current PermissionOverrides are lost!This behaves as if calling
sync(Channel)
with this Channel'sParent
.- Returns:
- ChannelManager for chaining convenience
- Throws:
java.lang.IllegalStateException
- If this Channel has no parentInsufficientPermissionException
- If the currently logged in account does not havePermission.MANAGE_PERMISSIONS
in this channel- See Also:
- Discord Documentation - Permission Syncing
-
sync
@CheckReturnValue public ChannelManager sync(Channel syncSource)
Syncs allPermissionOverrides
of this Channel with the given (Channel
).After this operation, all
PermissionOverrides
will be exactly the same as the ones from the syncSource.
That means that all current PermissionOverrides are lost!This will only work for Channels of the same
Guild
!.- Parameters:
syncSource
- The Channel from where all PermissionOverrides should be copied from- Returns:
- ChannelManager for chaining convenience
- Throws:
java.lang.IllegalArgumentException
- If the given snySource isnull
, this Channel or from a different Guild.InsufficientPermissionException
- If the currently logged in account does not havePermission.MANAGE_PERMISSIONS
in this channel- See Also:
- Discord Documentation - Permission Syncing
-
setName
@CheckReturnValue public ChannelManager setName(java.lang.String name)
Sets the name of the selectedChannel
.A channel name must not be
null
nor empty or more than 100 characters long!
TextChannel names may only be populated with alphanumeric (with underscore and dash).Example:
mod-only
orgeneric_name
Characters will automatically be lowercased by Discord for text channels!- Parameters:
name
- The new name for the selectedChannel
- Returns:
- ChannelManager for chaining convenience
- Throws:
java.lang.IllegalArgumentException
- If the provided name isnull
or not between 1-100 characters long
-
setParent
@CheckReturnValue public ChannelManager setParent(Category category)
Sets theParent Category
of the selectedChannel
.- Parameters:
category
- The new parent for the selectedChannel
- Returns:
- ChannelManager for chaining convenience
- Throws:
java.lang.IllegalStateException
- If the target is a category itselfjava.lang.IllegalArgumentException
- If the provided category is not from the same Guild- Since:
- 3.4.0
-
setPosition
@CheckReturnValue public ChannelManager setPosition(int position)
Sets the position of the selectedChannel
.To modify multiple channels you should use
Guild.
instead! This is not the same as looping through channels and using this to update positions!getController()
.modifyTextChannelPositions()
- Parameters:
position
- The new position for the selectedChannel
- Returns:
- ChannelManager for chaining convenience
-
setTopic
@CheckReturnValue public ChannelManager setTopic(java.lang.String topic)
Sets the topic of the selectedTextChannel
.A channel topic must not be more than
1024
characters long!
This is only available toTextChannels
- Parameters:
topic
- The new topic for the selectedTextChannel
,null
or empty String to reset- Returns:
- ChannelManager for chaining convenience
- Throws:
java.lang.UnsupportedOperationException
- If the selectedChannel
's type is notTEXT
java.lang.IllegalArgumentException
- If the provided topic is greater than1024
in length
-
setNSFW
@CheckReturnValue public ChannelManager setNSFW(boolean nsfw)
Sets the nsfw flag of the selectedTextChannel
.- Parameters:
nsfw
- The new nsfw flag for the selectedTextChannel
,- Returns:
- ChannelManager for chaining convenience
- Throws:
InsufficientPermissionException
- If the currently logged in account does not have the PermissionMANAGE_CHANNEL
java.lang.IllegalStateException
- If the selectedChannel
's type is notTEXT
-
setSlowmode
@CheckReturnValue public ChannelManager setSlowmode(int slowmode)
Sets the slowmode of the selectedTextChannel
.
Provide0
to reset the slowmode of theTextChannel
A channel slowmode must not be negative nor greater than
120
!
This is only available toTextChannels
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 new slowmode for the selectedTextChannel
- Returns:
- ChannelManager for chaining convenience
- Throws:
java.lang.IllegalStateException
- If the selectedChannel
's type is notTEXT
java.lang.IllegalArgumentException
- If the provided slowmode is negative or greater than120
-
setUserLimit
@CheckReturnValue public ChannelManager setUserLimit(int userLimit)
Sets the user-limit of the selectedVoiceChannel
.
Provide0
to reset the user-limit of theVoiceChannel
A channel user-limit must not be negative nor greater than
99
!
This is only available toVoiceChannels
- Parameters:
userLimit
- The new user-limit for the selectedVoiceChannel
- Returns:
- ChannelManager for chaining convenience
- Throws:
java.lang.IllegalStateException
- If the selectedChannel
's type is notVOICE
java.lang.IllegalArgumentException
- If the provided user-limit is negative or greater than99
-
setBitrate
@CheckReturnValue public ChannelManager setBitrate(int bitrate)
Sets the bitrate of the selectedVoiceChannel
.
The default value is64000
A channel bitrate must not be less than
8000
nor greater than96000
(for non-vip Guilds)!VIP Guilds
allow a bitrate for up to128000
.
This is only available toVoiceChannels
- Parameters:
bitrate
- The new bitrate for the selectedVoiceChannel
- Returns:
- ChannelManager for chaining convenience
- Throws:
java.lang.IllegalStateException
- If the selectedChannel
's type is notVOICE
java.lang.IllegalArgumentException
- If the provided bitrate is not between 8000-96000 (or 128000 for VIP Guilds)- See Also:
Guild.getFeatures()
-
-