Class ChannelManager


  • public class ChannelManager
    extends net.dv8tion.jda.core.managers.impl.ManagerBase
    Manager providing functionality to update one or more fields for a Guild 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()
    • Constructor Detail

      • ChannelManager

        public ChannelManager​(Channel channel)
        Creates a new ChannelManager instance
        Parameters:
        channel - Channel that should be modified
        Either Voice- or TextChannel
    • Method Detail

      • getChannel

        public Channel getChannel()
        The Channel that will be modified by this Manager instance
        Returns:
        The Channel
      • getGuild

        public Guild getGuild()
        The Guild this Manager's Channel is in.
        This is logically the same as calling getChannel().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 class net.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 class net.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
      • putPermissionOverride

        @CheckReturnValue
        public ChannelManager putPermissionOverride​(IPermissionHolder permHolder,
                                                    java.util.Collection<Permission> allow,
                                                    java.util.Collection<Permission> deny)
        Adds an override for the specified IPermissionHolder 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 holder
        allow - The permissions to grant, or null
        deny - The permissions to deny, or null
        Returns:
        ChannelManager for chaining convenience
        Throws:
        java.lang.IllegalArgumentException - If the provided permission holder is null
        InsufficientPermissionException - If the currently logged in account does not have Permission.MANAGE_PERMISSIONS in this channel
        See Also:
        putPermissionOverride(IPermissionHolder, long, long), EnumSet
      • setName

        @CheckReturnValue
        public ChannelManager setName​(java.lang.String name)
        Sets the name of the selected Channel.

        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 or generic_name
        Characters will automatically be lowercased by Discord for text channels!

        Parameters:
        name - The new name for the selected Channel
        Returns:
        ChannelManager for chaining convenience
        Throws:
        java.lang.IllegalArgumentException - If the provided name is null or not between 1-100 characters long
      • setParent

        @CheckReturnValue
        public ChannelManager setParent​(Category category)
        Sets the Parent Category of the selected Channel.
        Parameters:
        category - The new parent for the selected Channel
        Returns:
        ChannelManager for chaining convenience
        Throws:
        java.lang.IllegalStateException - If the target is a category itself
        java.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 selected Channel.

        To modify multiple channels you should use Guild.getController().modifyTextChannelPositions() instead! This is not the same as looping through channels and using this to update positions!

        Parameters:
        position - The new position for the selected Channel
        Returns:
        ChannelManager for chaining convenience
      • setTopic

        @CheckReturnValue
        public ChannelManager setTopic​(java.lang.String topic)
        Sets the topic of the selected TextChannel.

        A channel topic must not be more than 1024 characters long!
        This is only available to TextChannels

        Parameters:
        topic - The new topic for the selected TextChannel, null or empty String to reset
        Returns:
        ChannelManager for chaining convenience
        Throws:
        java.lang.UnsupportedOperationException - If the selected Channel's type is not TEXT
        java.lang.IllegalArgumentException - If the provided topic is greater than 1024 in length
      • setSlowmode

        @CheckReturnValue
        public ChannelManager setSlowmode​(int slowmode)
        Sets the slowmode of the selected TextChannel.
        Provide 0 to reset the slowmode of the TextChannel

        A channel slowmode must not be negative nor greater than 120!
        This is only available to TextChannels

        Note that only CLIENT type accounts are affected by slowmode, and that BOT accounts are immune to the restrictions.
        Having MESSAGE_MANAGE or MANAGE_CHANNEL permission also grants immunity to slowmode.

        Parameters:
        slowmode - The new slowmode for the selected TextChannel
        Returns:
        ChannelManager for chaining convenience
        Throws:
        java.lang.IllegalStateException - If the selected Channel's type is not TEXT
        java.lang.IllegalArgumentException - If the provided slowmode is negative or greater than 120
      • setUserLimit

        @CheckReturnValue
        public ChannelManager setUserLimit​(int userLimit)
        Sets the user-limit of the selected VoiceChannel.
        Provide 0 to reset the user-limit of the VoiceChannel

        A channel user-limit must not be negative nor greater than 99!
        This is only available to VoiceChannels

        Parameters:
        userLimit - The new user-limit for the selected VoiceChannel
        Returns:
        ChannelManager for chaining convenience
        Throws:
        java.lang.IllegalStateException - If the selected Channel's type is not VOICE
        java.lang.IllegalArgumentException - If the provided user-limit is negative or greater than 99
      • setBitrate

        @CheckReturnValue
        public ChannelManager setBitrate​(int bitrate)
        Sets the bitrate of the selected VoiceChannel.
        The default value is 64000

        A channel bitrate must not be less than 8000 nor greater than 96000 (for non-vip Guilds)! VIP Guilds allow a bitrate for up to 128000.
        This is only available to VoiceChannels

        Parameters:
        bitrate - The new bitrate for the selected VoiceChannel
        Returns:
        ChannelManager for chaining convenience
        Throws:
        java.lang.IllegalStateException - If the selected Channel's type is not VOICE
        java.lang.IllegalArgumentException - If the provided bitrate is not between 8000-96000 (or 128000 for VIP Guilds)
        See Also:
        Guild.getFeatures()