Interface ChannelAction<T extends GuildChannel>

    • Method Detail

      • timeout

        @Nonnull
        ChannelAction<T> timeout​(long timeout,
                                 @Nonnull
                                 java.util.concurrent.TimeUnit unit)
        Description copied from interface: AuditableRestAction
        Timeout for this RestAction instance.
        If the request doesn't get executed within the timeout it will fail.

        When a RestAction times out, it will fail with a TimeoutException. This is the same as deadline(System.currentTimeMillis() + unit.toMillis(timeout)).

        Example

        
         action.timeout(10, TimeUnit.SECONDS) // 10 seconds from now
               .queueAfter(20, SECONDS); // request will not be executed within deadline and timeout immediately after 20 seconds
         
        Specified by:
        timeout in interface AuditableRestAction<T extends GuildChannel>
        Specified by:
        timeout in interface RestAction<T extends GuildChannel>
        Parameters:
        timeout - The timeout to use
        unit - Unit for the timeout value
        Returns:
        The same RestAction instance with the applied timeout
        See Also:
        RestAction.setDefaultTimeout(long, TimeUnit)
      • deadline

        @Nonnull
        ChannelAction<T> deadline​(long timestamp)
        Description copied from interface: AuditableRestAction
        Similar to RestAction.timeout(long, TimeUnit) but schedules a deadline at which the request has to be completed.
        If the deadline is reached, the request will fail with a TimeoutException.

        This does not mean that the request will immediately timeout when the deadline is reached. JDA will check the deadline right before executing the request or within intervals in a worker thread. This only means the request will timeout if the deadline has passed.

        Example

        
         action.deadline(System.currentTimeMillis() + 10000) // 10 seconds from now
               .queueAfter(20, SECONDS); // request will not be executed within deadline and timeout immediately after 20 seconds
         
        Specified by:
        deadline in interface AuditableRestAction<T extends GuildChannel>
        Specified by:
        deadline in interface RestAction<T extends GuildChannel>
        Parameters:
        timestamp - Millisecond timestamp at which the request will timeout
        Returns:
        The same RestAction with the applied deadline
        See Also:
        RestAction.timeout(long, TimeUnit), RestAction.setDefaultTimeout(long, TimeUnit)
      • getGuild

        @Nonnull
        Guild getGuild()
        The guild to create this GuildChannel in
        Returns:
        The guild
      • setName

        @Nonnull
        @CheckReturnValue
        ChannelAction<T> setName​(@Nonnull
                                 java.lang.String name)
        Sets the name for the new GuildChannel
        Parameters:
        name - The not-null name for the new GuildChannel (1-100 chars long)
        Returns:
        The current ChannelAction, for chaining convenience
        Throws:
        java.lang.IllegalArgumentException - If the provided name is null or not between 1-100 chars long
      • setParent

        @Nonnull
        @CheckReturnValue
        ChannelAction<T> setParent​(@Nullable
                                   Category category)
        Sets the Category for the new GuildChannel. You can use syncPermissionOverrides() to sync the channel with the category.
        Parameters:
        category - The parent for the new GuildChannel
        Returns:
        The current ChannelAction, for chaining convenience
        Throws:
        java.lang.UnsupportedOperationException - If this ChannelAction is for a Category
        java.lang.IllegalArgumentException - If the provided category is null or not from this Guild
        See Also:
        syncPermissionOverrides()
      • setPosition

        @Nonnull
        @CheckReturnValue
        ChannelAction<T> setPosition​(@Nullable
                                     java.lang.Integer position)
        Sets the position where the new Channel should be inserted into. This refers to the raw position value, not the computed (relative) position.

        By default (or by providing this method with null), the position will automatically be computed based on the other Channels (inserted last in its respective group).

        Note: This does not shift the position values of existing Channels if the values collide.
        As a reminder: The ordering of Channels is determined first by its Category's position, then by its raw position value and finally by its id (younger Channels are below older ones)

        Parameters:
        position - The raw position value that should be used for the new Channel
        Returns:
        The current ChannelAction, for chaining convenience
        Throws:
        java.lang.IllegalArgumentException - If the provided position value is <0
      • setTopic

        @Nonnull
        @CheckReturnValue
        ChannelAction<T> setTopic​(@Nullable
                                  java.lang.String topic)
        Sets the topic for the new TextChannel
        Parameters:
        topic - The topic for the new GuildChannel (max 1024 chars)
        Returns:
        The current ChannelAction, for chaining convenience
        Throws:
        java.lang.UnsupportedOperationException - If this ChannelAction is not for a TextChannel
        java.lang.IllegalArgumentException - If the provided topic is longer than 1024 chars
      • setNSFW

        @Nonnull
        @CheckReturnValue
        ChannelAction<T> setNSFW​(boolean nsfw)
        Sets the NSFW flag for the new TextChannel
        Parameters:
        nsfw - The NSFW flag for the new GuildChannel
        Returns:
        The current ChannelAction, for chaining convenience
        Throws:
        java.lang.UnsupportedOperationException - If this ChannelAction is not for a TextChannel
      • setSlowmode

        @Nonnull
        @CheckReturnValue
        ChannelAction<T> setSlowmode​(int slowmode)
        Sets the slowmode value, which limits the amount of time that individual users must wait between sending messages in the new TextChannel. This is measured in seconds.

        Note: Bots are unaffected by this.
        Having MESSAGE_MANAGE or MANAGE_CHANNEL permission also grants immunity to slowmode.

        Parameters:
        slowmode - The number of seconds required to wait between sending messages in the channel.
        Returns:
        The current ChannelAction, for chaining convenience
        Throws:
        java.lang.UnsupportedOperationException - If this ChannelAction is not for a TextChannel
        java.lang.IllegalArgumentException - If the slowmode is greater than TextChannel.MAX_SLOWMODE, or less than 0
      • setNews

        @Nonnull
        @CheckReturnValue
        ChannelAction<T> setNews​(boolean news)
        Sets the news flag for the new TextChannel. Announcement-/News-Channels can be used to crosspost messages to other guilds.
        Parameters:
        news - The news flag for the new GuildChannel
        Returns:
        The current ChannelAction, for chaining convenience
        Throws:
        java.lang.UnsupportedOperationException - If this ChannelAction is not for a TextChannel
        java.lang.IllegalStateException - If news is true and the guild doesn't have the NEWS feature
        Since:
        4.2.1
        See Also:
        TextChannel.isNews()
      • addPermissionOverride

        @Nonnull
        @CheckReturnValue
        default ChannelAction<T> addPermissionOverride​(@Nonnull
                                                       IPermissionHolder target,
                                                       @Nullable
                                                       java.util.Collection<Permission> allow,
                                                       @Nullable
                                                       java.util.Collection<Permission> deny)
        Adds a new Role or Member PermissionOverride for the new GuildChannel.

        If setting permission overwrites, only permissions your bot has in the guild can be allowed/denied.

        Example:

        
         Role role = guild.getPublicRole();
         EnumSet<Permission> allow = EnumSet.of(Permission.MESSAGE_READ);
         EnumSet<Permission> deny = EnumSet.of(Permission.MESSAGE_WRITE);
         channelAction.addPermissionOverride(role, allow, deny);
         
        Parameters:
        target - The not-null Role or Member for the override
        allow - The granted Permissions for the override or null
        deny - The denied Permissions for the override or null
        Returns:
        The current ChannelAction, for chaining convenience
        Throws:
        InsufficientPermissionException - If any permission is set in allow/deny that the currently logged in account is missing, unless Permission.MANAGE_PERMISSIONS or Permission.MANAGE_ROLES is granted to it within the context of the parent category.
        java.lang.IllegalArgumentException - If the specified target is null or not within the same guild.
        See Also:
        EnumSet
      • addMemberPermissionOverride

        @Nonnull
        @CheckReturnValue
        default ChannelAction<T> addMemberPermissionOverride​(long memberId,
                                                             @Nullable
                                                             java.util.Collection<Permission> allow,
                                                             @Nullable
                                                             java.util.Collection<Permission> deny)
        Adds a new Member PermissionOverride for the new GuildChannel.

        If setting permission overwrites, only permissions your bot has in the guild can be allowed/denied.

        Example:

        
         long userId = user.getIdLong();
         EnumSet<Permission> allow = EnumSet.of(Permission.MESSAGE_READ);
         EnumSet<Permission> deny = EnumSet.of(Permission.MESSAGE_WRITE);
         channelAction.addMemberPermissionOverride(userId, allow, deny);
         
        Parameters:
        memberId - The id for the member
        allow - The granted Permissions for the override or null
        deny - The denied Permissions for the override or null
        Returns:
        The current ChannelAction, for chaining convenience
        Throws:
        InsufficientPermissionException - If any permission is set in allow/deny that the currently logged in account is missing, unless Permission.MANAGE_PERMISSIONS or Permission.MANAGE_ROLES is granted to it within the context of the parent category.
        See Also:
        EnumSet
      • addRolePermissionOverride

        @Nonnull
        @CheckReturnValue
        default ChannelAction<T> addRolePermissionOverride​(long roleId,
                                                           @Nullable
                                                           java.util.Collection<Permission> allow,
                                                           @Nullable
                                                           java.util.Collection<Permission> deny)
        Adds a new Role PermissionOverride for the new GuildChannel.

        If setting permission overwrites, only permissions your bot has in the guild can be allowed/denied.

        Example:

        
         long roleId = role.getIdLong();
         EnumSet<Permission> allow = EnumSet.of(Permission.MESSAGE_READ);
         EnumSet<Permission> deny = EnumSet.of(Permission.MESSAGE_WRITE);
         channelAction.addRolePermissionOverride(roleId, allow, deny);
         
        Parameters:
        roleId - The id for the role
        allow - The granted Permissions for the override or null
        deny - The denied Permissions for the override or null
        Returns:
        The current ChannelAction, for chaining convenience
        Throws:
        InsufficientPermissionException - If any permission is set in allow/deny that the currently logged in account is missing, unless Permission.MANAGE_PERMISSIONS or Permission.MANAGE_ROLES is granted to it within the context of the parent category.
        See Also:
        EnumSet
      • removePermissionOverride

        @Nonnull
        @CheckReturnValue
        ChannelAction<T> removePermissionOverride​(long id)
        Removes any existing override with the provided id.
        If no override with the provided id exists, this method does nothing.
        Parameters:
        id - The member or role id of the override
        Returns:
        The current ChannelAction, for chaining convenience
      • removePermissionOverride

        @Nonnull
        @CheckReturnValue
        default ChannelAction<T> removePermissionOverride​(@Nonnull
                                                          java.lang.String id)
        Removes any existing override with the provided id.
        If no override with the provided id exists, this method does nothing.
        Parameters:
        id - The member or role id of the override
        Returns:
        The current ChannelAction, for chaining convenience
        Throws:
        java.lang.IllegalArgumentException - If the provided string is not a valid snowflake or null
      • removePermissionOverride

        @Nonnull
        @CheckReturnValue
        default ChannelAction<T> removePermissionOverride​(@Nonnull
                                                          IPermissionHolder holder)
        Removes any existing override with the provided role/member.
        If no override for the provided role/member exists, this method does nothing.
        Parameters:
        holder - The member or role of the override
        Returns:
        The current ChannelAction, for chaining convenience
        Throws:
        java.lang.IllegalArgumentException - If the provided permission holder is null
      • clearPermissionOverrides

        @Nonnull
        @CheckReturnValue
        ChannelAction<T> clearPermissionOverrides()
        Removes all currently configured permission overrides
        Returns:
        The current ChannelAction, for chaining convenience
      • syncPermissionOverrides

        @Nonnull
        @CheckReturnValue
        ChannelAction<T> syncPermissionOverrides()
        Syncs the permission overrides of the channel with the category.

        If setting permission overwrites, only permissions your bot has in the guild can be allowed/denied. In order to properly sync permissions the currently logged in account must have all allowed/denied permissions or Permission.MANAGE_ROLES in the parent category.

        Returns:
        The current ChannelAction, for chaining convenience
        Throws:
        java.lang.IllegalArgumentException - If no parent has been configured. You have to use setParent(Category) before calling this method.
      • setBitrate

        @Nonnull
        @CheckReturnValue
        ChannelAction<T> setBitrate​(@Nullable
                                    java.lang.Integer bitrate)
        Sets the bitrate for the new VoiceChannel
        Parameters:
        bitrate - The bitrate for the new VoiceChannel in bps (limits 8000 <= bitrate <= Guild.getMaxBitrate()) or null to use the default 64kbps.
        Returns:
        The current ChannelAction, for chaining convenience
        Throws:
        java.lang.UnsupportedOperationException - If this ChannelAction is not for a VoiceChannel
        java.lang.IllegalArgumentException - If the provided bitrate is less than 8000 or greater than Guild.getMaxBitrate()
      • setUserlimit

        @Nonnull
        @CheckReturnValue
        ChannelAction<T> setUserlimit​(@Nullable
                                      java.lang.Integer userlimit)
        Sets the userlimit for the new VoiceChannel
        Parameters:
        userlimit - The userlimit for the new VoiceChannel or null/0 to use no limit,
        Returns:
        The current ChannelAction, for chaining convenience
        Throws:
        java.lang.UnsupportedOperationException - If this ChannelAction is not for a VoiceChannel
        java.lang.IllegalArgumentException - If the provided userlimit is negative or above 99