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 longBITRATEUsed to reset the bitrate fieldstatic longNAMEUsed to reset the name fieldstatic longNEWSUsed to reset the channel type fieldstatic longNSFWUsed to reset the nsfw fieldstatic longPARENTUsed to reset the parent fieldstatic longPERMISSIONUsed to reset the permission fieldstatic longPOSITIONUsed to reset the position fieldstatic longREGIONUsed to reset the region fieldstatic longSLOWMODEUsed to reset the rate-limit per user fieldstatic longTOPICUsed to reset the topic fieldstatic longUSERLIMITUsed to reset the userlimit field
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description ChannelManagerclearOverridesAdded()Clears the overrides added viaputPermissionOverride(IPermissionHolder, Collection, Collection).ChannelManagerclearOverridesRemoved()Clears the overrides removed viaremovePermissionOverride(IPermissionHolder).GuildChannelgetChannel()TheGuildChannelthat will be modified by this Manager instancedefault GuildgetGuild()TheGuildthis Manager'sGuildChannelis in.default ChannelTypegetType()TheChannelTypeChannelManagerputMemberPermissionOverride(long memberId, long allow, long deny)Adds an override for the specified member with the provided raw bitmasks as allowed and denied permissions.default ChannelManagerputMemberPermissionOverride(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.ChannelManagerputPermissionOverride(IPermissionHolder permHolder, long allow, long deny)Adds an override for the specifiedIPermissionHolderwith the provided raw bitmasks as allowed and denied permissions.default ChannelManagerputPermissionOverride(IPermissionHolder permHolder, java.util.Collection<Permission> allow, java.util.Collection<Permission> deny)Adds an override for the specifiedIPermissionHolderwith the provided permission sets as allowed and denied permissions.ChannelManagerputRolePermissionOverride(long roleId, long allow, long deny)Adds an override for the specified role with the provided raw bitmasks as allowed and denied permissions.default ChannelManagerputRolePermissionOverride(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.ChannelManagerremovePermissionOverride(long id)Removes thePermissionOverridefor the specified member or role ID.ChannelManagerremovePermissionOverride(IPermissionHolder permHolder)Removes thePermissionOverridefor the specifiedIPermissionHolder.ChannelManagerreset(long fields)Resets the fields specified by the provided bit-flag pattern.ChannelManagerreset(long... fields)Resets the fields specified by the provided bit-flag patterns.ChannelManagersetBitrate(int bitrate)Sets the bitrate of the selectedVoiceChannel.ChannelManagersetName(java.lang.String name)Sets the name of the selectedGuildChannel.ChannelManagersetNews(boolean news)Sets the news flag of the selectedTextChannel.ChannelManagersetNSFW(boolean nsfw)Sets the nsfw flag of the selectedTextChannel.ChannelManagersetParent(Category category)Sets theParent Categoryof the selectedGuildChannel.ChannelManagersetPosition(int position)Sets the position of the selectedGuildChannel.ChannelManagersetRegion(Region region)Sets theRegionof the selectedVoiceChannel.ChannelManagersetSlowmode(int slowmode)Sets the slowmode of the selectedTextChannel.ChannelManagersetTopic(java.lang.String topic)Sets the topic of the selectedTextChannelorStageChannel.ChannelManagersetUserLimit(int userLimit)Sets the user-limit of the selectedVoiceChannel.default ChannelManagersync()Syncs allPermissionOverridesof this GuildChannel with its parent (Category).ChannelManagersync(GuildChannel syncSource)Syncs allPermissionOverridesof 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:
resetin 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:
resetin interfaceManager<ChannelManager>- Parameters:
fields- Integer values containing the flags to reset.- Returns:
- ChannelManager for chaining convenience
-
getChannel
@Nonnull GuildChannel getChannel()
TheGuildChannelthat will be modified by this Manager instance- Returns:
- The
GuildChannel
-
getType
@Nonnull default ChannelType getType()
TheChannelType- Returns:
- The ChannelType
-
getGuild
@Nonnull default Guild getGuild()
TheGuildthis Manager'sGuildChannelis 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 specifiedIPermissionHolderwith 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 isnullInsufficientPermissionException- If the currently logged in account does not havePermission.MANAGE_PERMISSIONSin this channel, or tries to set permissions it does not have without havingPermission.MANAGE_PERMISSIONSexplicitly 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 specifiedIPermissionHolderwith 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 isnullInsufficientPermissionException- If the currently logged in account does not havePermission.MANAGE_PERMISSIONSin this channel, or tries to set permissions it does not have without havingPermission.MANAGE_PERMISSIONSexplicitly 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_PERMISSIONSin this channel, or tries to set permissions it does not have without havingPermission.MANAGE_PERMISSIONSexplicitly 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_PERMISSIONSin this channel, or tries to set permissions it does not have without havingPermission.MANAGE_PERMISSIONSexplicitly 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_PERMISSIONSin this channel, or tries to set permissions it does not have without havingPermission.MANAGE_PERMISSIONSexplicitly 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_PERMISSIONSin this channel, or tries to set permissions it does not have without havingPermission.MANAGE_PERMISSIONSexplicitly for this channel through an override.- See Also:
putMemberPermissionOverride(long, long, long),EnumSet
-
removePermissionOverride
@Nonnull @CheckReturnValue ChannelManager removePermissionOverride(@Nonnull IPermissionHolder permHolder)
Removes thePermissionOverridefor 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 isnullInsufficientPermissionException- If the currently logged in account does not havePermission.MANAGE_PERMISSIONSin this channel
-
removePermissionOverride
@Nonnull @CheckReturnValue ChannelManager removePermissionOverride(long id)
Removes thePermissionOverridefor 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_PERMISSIONSin this channel
-
sync
@Nonnull @CheckReturnValue default ChannelManager sync()
Syncs allPermissionOverridesof this GuildChannel with its parent (Category).After this operation, all
PermissionOverrideswill 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_PERMISSIONSin 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 allPermissionOverridesof this GuildChannel with the given (GuildChannel).After this operation, all
PermissionOverrideswill 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_PERMISSIONSin 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
nullnor empty or more than 100 characters long!
TextChannel names may only be populated with alphanumeric (with underscore and dash).Example:
mod-onlyorgeneric_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 isnullor not between 1-100 characters long
-
setParent
@Nonnull @CheckReturnValue ChannelManager setParent(@Nullable Category category)
Sets theParent Categoryof 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 selectedTextChannelorStageChannel.A channel topic must not be more than
1024characters long!
This is only available toTextChannels- Parameters:
topic- The new topic for the selected channel,nullor empty String to reset- Returns:
- ChannelManager for chaining convenience
- Throws:
java.lang.UnsupportedOperationException- If the selectedGuildChannel's type is notTEXTjava.lang.IllegalArgumentException- If the provided topic is greater than1024in 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.
Provide0to reset the slowmode of theTextChannelA channel slowmode must not be negative nor greater than
TextChannel.MAX_SLOWMODE!
This is only available toTextChannelsNote: Bots are unaffected by this.
HavingMESSAGE_MANAGEorMANAGE_CHANNELpermission 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 notTEXTjava.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.
Provide0to reset the user-limit of theVoiceChannelA 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 notVOICEjava.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 is64000A channel bitrate must not be less than
8000nor 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 notVOICEjava.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 theRegionof the selectedVoiceChannel.
The default value isRegion.AUTOMATICPossible values are:Region.AUTOMATICRegion.US_WESTRegion.US_EASTRegion.US_CENTRALRegion.US_SOUTHRegion.SINGAPORERegion.SOUTH_AFRICARegion.SYDNEYRegion.EUROPERegion.INDIARegion.SOUTH_KOREARegion.BRAZILRegion.JAPANRegion.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 notVOICEjava.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 notTEXTjava.lang.IllegalStateException- Ifnewsistrueand the guild doesn't have the NEWS feature- Since:
- 4.2.1
- See Also:
Guild.getFeatures(),TextChannel.isNews()
-
-