Interface ChannelManager
-
- All Superinterfaces:
AuditableRestAction<Void>
,Manager<ChannelManager>
,RestAction<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
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
-
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
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, Collection<Permission> allow, 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(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(String name)
Sets the name of the selectedGuildChannel
.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
setSlowmode(int slowmode)
Sets the slowmode of the selectedTextChannel
.ChannelManager
setTopic(String topic)
Sets the topic of the selectedTextChannel
.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.requests.RestAction
complete, complete, completeAfter, getJDA, queue, queue, queue, queueAfter, queueAfter, queueAfter, queueAfter, queueAfter, queueAfter, submit, submit, submitAfter, submitAfter
-
-
-
-
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
-
-
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:
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
@Nonnull @CheckReturnValue default ChannelManager putPermissionOverride(@Nonnull IPermissionHolder permHolder, @Nullable Collection<Permission> allow, @Nullable 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:
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
@Nonnull @CheckReturnValue ChannelManager removePermissionOverride(@Nonnull 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:
IllegalArgumentException
- If the provided permission holder isnull
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:
IllegalStateException
- If this GuildChannel has no parentInsufficientPermissionException
- If the currently logged in account does not havePermission.MANAGE_PERMISSIONS
in this channel- 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:
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- See Also:
- Discord Documentation - Permission Syncing
-
setName
@Nonnull @CheckReturnValue ChannelManager setName(@Nonnull 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:
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:
IllegalStateException
- If the target is a category itselfIllegalArgumentException
- 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 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:
UnsupportedOperationException
- If the selectedGuildChannel
's type is notTEXT
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:
InsufficientPermissionException
- If the currently logged in account does not have the PermissionMANAGE_CHANNEL
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 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:
IllegalStateException
- If the selectedGuildChannel
's type is notTEXT
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:
IllegalStateException
- If the selectedGuildChannel
's type is notVOICE
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:
IllegalStateException
- If the selectedGuildChannel
's type is notVOICE
IllegalArgumentException
- If the provided bitrate is less than 8000 or greater thanGuild.getMaxBitrate()
.- See Also:
Guild.getFeatures()
-
-