Interface ChannelManager
-
- All Superinterfaces:
AuditableRestAction<java.lang.Void>
,Manager<ChannelManager>
,RestAction<java.lang.Void>
public interface ChannelManager extends Manager<ChannelManager>
Manager providing functionality to update one or more fields for aGuildChannel
.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:
GuildChannel.getManager()
-
-
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
NEWS
Used to reset the channel type 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
REGION
Used to reset the region 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
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description ChannelManager
clearOverridesAdded()
Clears the overrides added viaputPermissionOverride(IPermissionHolder, Collection, Collection)
.ChannelManager
clearOverridesRemoved()
Clears the overrides removed viaremovePermissionOverride(IPermissionHolder)
.GuildChannel
getChannel()
TheGuildChannel
that will be modified by this Manager instancedefault Guild
getGuild()
TheGuild
this Manager'sGuildChannel
is in.default ChannelType
getType()
TheChannelType
ChannelManager
putMemberPermissionOverride(long memberId, long allow, long deny)
Adds an override for the specified member with the provided raw bitmasks as allowed and denied permissions.default ChannelManager
putMemberPermissionOverride(long memberId, java.util.Collection<Permission> allow, java.util.Collection<Permission> deny)
Adds an override for the specified member with the provided permission sets as allowed and denied permissions.ChannelManager
putPermissionOverride(IPermissionHolder permHolder, long allow, long deny)
Adds an override for the specifiedIPermissionHolder
with the provided raw bitmasks as allowed and denied permissions.default 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
putRolePermissionOverride(long roleId, long allow, long deny)
Adds an override for the specified role with the provided raw bitmasks as allowed and denied permissions.default ChannelManager
putRolePermissionOverride(long roleId, java.util.Collection<Permission> allow, java.util.Collection<Permission> deny)
Adds an override for the specified role with the provided permission sets as allowed and denied permissions.ChannelManager
removePermissionOverride(long id)
Removes thePermissionOverride
for the specified member or role ID.ChannelManager
removePermissionOverride(IPermissionHolder permHolder)
Removes thePermissionOverride
for the specifiedIPermissionHolder
.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 selectedGuildChannel
.ChannelManager
setNews(boolean news)
Sets the news flag of the selectedTextChannel
.ChannelManager
setNSFW(boolean nsfw)
Sets the nsfw flag of the selectedTextChannel
.ChannelManager
setParent(Category category)
Sets theParent Category
of the selectedGuildChannel
.ChannelManager
setPosition(int position)
Sets the position of the selectedGuildChannel
.ChannelManager
setRegion(Region region)
Sets theRegion
of the selectedVoiceChannel
.ChannelManager
setSlowmode(int slowmode)
Sets the slowmode of the selectedTextChannel
.ChannelManager
setTopic(java.lang.String topic)
Sets the topic of the selectedTextChannel
orStageChannel
.ChannelManager
setUserLimit(int userLimit)
Sets the user-limit of the selectedVoiceChannel
.default ChannelManager
sync()
Syncs allPermissionOverrides
of this GuildChannel with its parent (Category
).ChannelManager
sync(GuildChannel syncSource)
Syncs allPermissionOverrides
of this GuildChannel with the given (GuildChannel
).-
Methods inherited from interface net.dv8tion.jda.api.requests.restaction.AuditableRestAction
reason
-
Methods inherited from interface net.dv8tion.jda.api.managers.Manager
deadline, reset, setCheck, timeout
-
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
-
-
-
-
Field Detail
-
NAME
static final long NAME
Used to reset the name field- See Also:
- Constant Field Values
-
PARENT
static final long PARENT
Used to reset the parent field- See Also:
- Constant Field Values
-
TOPIC
static final long TOPIC
Used to reset the topic field- See Also:
- Constant Field Values
-
POSITION
static final long POSITION
Used to reset the position field- See Also:
- Constant Field Values
-
NSFW
static final long NSFW
Used to reset the nsfw field- See Also:
- Constant Field Values
-
USERLIMIT
static final long USERLIMIT
Used to reset the userlimit field- See Also:
- Constant Field Values
-
BITRATE
static final long BITRATE
Used to reset the bitrate field- See Also:
- Constant Field Values
-
PERMISSION
static final long PERMISSION
Used to reset the permission field- See Also:
- Constant Field Values
-
SLOWMODE
static final long SLOWMODE
Used to reset the rate-limit per user field- See Also:
- Constant Field Values
-
NEWS
static final long NEWS
Used to reset the channel type field- See Also:
- Constant Field Values
-
REGION
static final long REGION
Used to reset the region field- See Also:
- Constant Field Values
-
-
Method Detail
-
reset
@Nonnull 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:
- Specified by:
reset
in interfaceManager<ChannelManager>
- Parameters:
fields
- Integer value containing the flags to reset.- Returns:
- ChannelManager for chaining convenience
-
reset
@Nonnull ChannelManager reset(long... fields)
Resets the fields specified by the provided bit-flag patterns.
Example:manager.reset(ChannelManager.NAME, ChannelManager.PARENT);
Flag Constants:
- Specified by:
reset
in interfaceManager<ChannelManager>
- Parameters:
fields
- Integer values containing the flags to reset.- Returns:
- ChannelManager for chaining convenience
-
getChannel
@Nonnull GuildChannel getChannel()
TheGuildChannel
that will be modified by this Manager instance- Returns:
- The
GuildChannel
-
getType
@Nonnull default ChannelType getType()
TheChannelType
- Returns:
- The ChannelType
-
getGuild
@Nonnull default Guild getGuild()
TheGuild
this Manager'sGuildChannel
is in.
This is logically the same as callinggetChannel().getGuild()
- Returns:
- The parent
Guild
-
clearOverridesAdded
@Nonnull @CheckReturnValue ChannelManager clearOverridesAdded()
Clears the overrides added viaputPermissionOverride(IPermissionHolder, Collection, Collection)
.- Returns:
- ChannelManager for chaining convenience
-
clearOverridesRemoved
@Nonnull @CheckReturnValue ChannelManager clearOverridesRemoved()
Clears the overrides removed viaremovePermissionOverride(IPermissionHolder)
.- Returns:
- ChannelManager for chaining convenience
-
putPermissionOverride
@Nonnull @CheckReturnValue ChannelManager putPermissionOverride(@Nonnull 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 replaced 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, or tries to set permissions it does not have without havingPermission.MANAGE_PERMISSIONS
explicitly for this channel through an override.- See Also:
putPermissionOverride(IPermissionHolder, Collection, Collection)
,Permission.getRaw(Permission...)
-
putPermissionOverride
@Nonnull @CheckReturnValue default ChannelManager putPermissionOverride(@Nonnull IPermissionHolder permHolder, @Nullable java.util.Collection<Permission> allow, @Nullable 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 replaced 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, or tries to set permissions it does not have without havingPermission.MANAGE_PERMISSIONS
explicitly for this channel through an override.- See Also:
putPermissionOverride(IPermissionHolder, long, long)
,EnumSet
-
putRolePermissionOverride
@Nonnull @CheckReturnValue ChannelManager putRolePermissionOverride(long roleId, long allow, long deny)
Adds an override for the specified role with the provided raw bitmasks as allowed and denied permissions. If the role already had an override on this channel it will be replaced instead.- Parameters:
roleId
- The ID of the role to set permissions forallow
- The bitmask to grantdeny
- The bitmask to deny- Returns:
- ChannelManager for chaining convenience
- Throws:
InsufficientPermissionException
- If the currently logged in account does not havePermission.MANAGE_PERMISSIONS
in this channel, or tries to set permissions it does not have without havingPermission.MANAGE_PERMISSIONS
explicitly for this channel through an override.- See Also:
putRolePermissionOverride(long, Collection, Collection)
,Permission.getRaw(Permission...)
-
putRolePermissionOverride
@Nonnull @CheckReturnValue default ChannelManager putRolePermissionOverride(long roleId, @Nullable java.util.Collection<Permission> allow, @Nullable java.util.Collection<Permission> deny)
Adds an override for the specified role with the provided permission sets as allowed and denied permissions. If the role already had an override on this channel it will be replaced instead.- Parameters:
roleId
- The ID of the role to set permissions forallow
- The permissions to grant, or nulldeny
- The permissions to deny, or null- Returns:
- ChannelManager for chaining convenience
- Throws:
InsufficientPermissionException
- If the currently logged in account does not havePermission.MANAGE_PERMISSIONS
in this channel, or tries to set permissions it does not have without havingPermission.MANAGE_PERMISSIONS
explicitly for this channel through an override.- See Also:
putRolePermissionOverride(long, long, long)
,EnumSet
-
putMemberPermissionOverride
@Nonnull @CheckReturnValue ChannelManager putMemberPermissionOverride(long memberId, long allow, long deny)
Adds an override for the specified member with the provided raw bitmasks as allowed and denied permissions. If the member already had an override on this channel it will be replaced instead.- Parameters:
memberId
- The ID of the member to set permissions forallow
- The bitmask to grantdeny
- The bitmask to deny- Returns:
- ChannelManager for chaining convenience
- Throws:
InsufficientPermissionException
- If the currently logged in account does not havePermission.MANAGE_PERMISSIONS
in this channel, or tries to set permissions it does not have without havingPermission.MANAGE_PERMISSIONS
explicitly for this channel through an override.- See Also:
putMemberPermissionOverride(long, Collection, Collection)
,Permission.getRaw(Permission...)
-
putMemberPermissionOverride
@Nonnull @CheckReturnValue default ChannelManager putMemberPermissionOverride(long memberId, @Nullable java.util.Collection<Permission> allow, @Nullable java.util.Collection<Permission> deny)
Adds an override for the specified member with the provided permission sets as allowed and denied permissions. If the member already had an override on this channel it will be replaced instead.- Parameters:
memberId
- The ID of the member to set permissions forallow
- The permissions to grant, or nulldeny
- The permissions to deny, or null- Returns:
- ChannelManager for chaining convenience
- Throws:
InsufficientPermissionException
- If the currently logged in account does not havePermission.MANAGE_PERMISSIONS
in this channel, or tries to set permissions it does not have without havingPermission.MANAGE_PERMISSIONS
explicitly for this channel through an override.- See Also:
putMemberPermissionOverride(long, long, long)
,EnumSet
-
removePermissionOverride
@Nonnull @CheckReturnValue ChannelManager removePermissionOverride(@Nonnull IPermissionHolder permHolder)
Removes thePermissionOverride
for the specifiedIPermissionHolder
. If no override existed for this member or role, 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
-
removePermissionOverride
@Nonnull @CheckReturnValue ChannelManager removePermissionOverride(long id)
Removes thePermissionOverride
for the specified member or role ID. If no override existed for this member or role, this does nothing.- Parameters:
id
- The ID of the permission holder- Returns:
- ChannelManager for chaining convenience
- Throws:
InsufficientPermissionException
- If the currently logged in account does not havePermission.MANAGE_PERMISSIONS
in this channel
-
sync
@Nonnull @CheckReturnValue default ChannelManager sync()
Syncs allPermissionOverrides
of this GuildChannel 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(net.dv8tion.jda.api.entities.GuildChannel)
with this GuildChannel'sParent
.- Returns:
- ChannelManager for chaining convenience
- Throws:
java.lang.IllegalStateException
- If this GuildChannel has no parentInsufficientPermissionException
- If the currently logged in account does not havePermission.MANAGE_PERMISSIONS
in this channel orIPermissionHolder.canSync(GuildChannel, GuildChannel)
is false for the self member.- See Also:
- Discord Documentation - Permission Syncing
-
sync
@Nonnull @CheckReturnValue ChannelManager sync(@Nonnull GuildChannel syncSource)
Syncs allPermissionOverrides
of this GuildChannel with the given (GuildChannel
).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 GuildChannel from where all PermissionOverrides should be copied from- Returns:
- ChannelManager for chaining convenience
- Throws:
java.lang.IllegalArgumentException
- If the given snySource isnull
, this GuildChannel or from a different Guild.InsufficientPermissionException
- If the currently logged in account does not havePermission.MANAGE_PERMISSIONS
in this channel orIPermissionHolder.canSync(GuildChannel, GuildChannel)
is false for the self member.- See Also:
- Discord Documentation - Permission Syncing
-
setName
@Nonnull @CheckReturnValue ChannelManager setName(@Nonnull java.lang.String name)
Sets the name of the selectedGuildChannel
.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 selectedGuildChannel
- Returns:
- ChannelManager for chaining convenience
- Throws:
java.lang.IllegalArgumentException
- If the provided name isnull
or not between 1-100 characters long
-
setParent
@Nonnull @CheckReturnValue ChannelManager setParent(@Nullable Category category)
Sets theParent Category
of the selectedGuildChannel
.- Parameters:
category
- The new parent for the selectedGuildChannel
- 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
@Nonnull @CheckReturnValue ChannelManager setPosition(int position)
Sets the position of the selectedGuildChannel
.To modify multiple channels you should use
Guild.
instead! This is not the same as looping through channels and using this to update positions!modifyTextChannelPositions()
- Parameters:
position
- The new position for the selectedGuildChannel
- Returns:
- ChannelManager for chaining convenience
-
setTopic
@Nonnull @CheckReturnValue ChannelManager setTopic(@Nullable java.lang.String topic)
Sets the topic of the selectedTextChannel
orStageChannel
.A channel topic must not be more than
1024
characters long!
This is only available toTextChannels
- Parameters:
topic
- The new topic for the selected channel,null
or empty String to reset- Returns:
- ChannelManager for chaining convenience
- Throws:
java.lang.UnsupportedOperationException
- If the selectedGuildChannel
's type is notTEXT
java.lang.IllegalArgumentException
- If the provided topic is greater than1024
in length
-
setNSFW
@Nonnull @CheckReturnValue 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:
java.lang.IllegalStateException
- If the selectedGuildChannel
's type is notTEXT
-
setSlowmode
@Nonnull @CheckReturnValue 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
TextChannel.MAX_SLOWMODE
!
This is only available toTextChannels
Note: Bots are unaffected by this.
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 selectedGuildChannel
's type is notTEXT
java.lang.IllegalArgumentException
- If the provided slowmode is negative or greater thanTextChannel.MAX_SLOWMODE
-
setUserLimit
@Nonnull @CheckReturnValue 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 selectedGuildChannel
's type is notVOICE
java.lang.IllegalArgumentException
- If the provided user-limit is negative or greater than99
-
setBitrate
@Nonnull @CheckReturnValue 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 thanGuild.getMaxBitrate()
!
This is only available toVoiceChannels
- Parameters:
bitrate
- The new bitrate for the selectedVoiceChannel
- Returns:
- ChannelManager for chaining convenience
- Throws:
java.lang.IllegalStateException
- If the selectedGuildChannel
's type is notVOICE
java.lang.IllegalArgumentException
- If the provided bitrate is less than 8000 or greater thanGuild.getMaxBitrate()
.- See Also:
Guild.getFeatures()
-
setRegion
@Nonnull @CheckReturnValue ChannelManager setRegion(Region region)
Sets theRegion
of the selectedVoiceChannel
.
The default value isRegion.AUTOMATIC
Possible values are:Region.AUTOMATIC
Region.US_WEST
Region.US_EAST
Region.US_CENTRAL
Region.US_SOUTH
Region.SINGAPORE
Region.SOUTH_AFRICA
Region.SYDNEY
Region.EUROPE
Region.INDIA
Region.SOUTH_KOREA
Region.BRAZIL
Region.JAPAN
Region.RUSSIA
This is only available toVoiceChannels
!- Parameters:
region
- The newRegion
- Returns:
- ChannelManager for chaining convenience
- Throws:
java.lang.IllegalStateException
- If the selectedGuildChannel
's type is notVOICE
java.lang.IllegalArgumentException
- If the provided Region is not in the list of usable values
-
setNews
@Nonnull @CheckReturnValue ChannelManager setNews(boolean news)
Sets the news flag of the selectedTextChannel
. Announcement-/News-Channels can be used to crosspost messages to other guilds.- Parameters:
news
- The new news flag for the selectedTextChannel
,- Returns:
- ChannelManager for chaining convenience
- Throws:
java.lang.IllegalStateException
- If the selectedGuildChannel
's type is notTEXT
java.lang.IllegalStateException
- Ifnews
istrue
and the guild doesn't have the NEWS feature- Since:
- 4.2.1
- See Also:
Guild.getFeatures()
,TextChannel.isNews()
-
-