Interface ChannelAction<T extends GuildChannel>

Type Parameters:
T - The type of channel to create
All Superinterfaces:
AuditableRestAction<T>, FluentAuditableRestAction<T, ChannelAction<T>>, RestAction<T>

public interface ChannelAction<T extends GuildChannel> extends FluentAuditableRestAction<T, ChannelAction<T>>
Extension of RestAction specifically designed to create a GuildChannel. This extension allows setting properties before executing the action.
Since:
3.0
See Also:
  • Method Details

    • getGuild

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

      @Nonnull ChannelType getType()
      The ChannelType for the resulting channel
      Returns:
      The channel type
    • setName

      @Nonnull @CheckReturnValue ChannelAction<T> setName(@Nonnull String name)
      Sets the name for the new GuildChannel
      Parameters:
      name - The not-null name for the new GuildChannel (1-100 characters long)
      Returns:
      The current ChannelAction, for chaining convenience
      Throws:
      IllegalArgumentException - If the provided name is null or not between 1-100 characters 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:
      UnsupportedOperationException - If this ChannelAction is for a Category
      IllegalArgumentException - If the provided category is null or not from this Guild
      See Also:
    • setPosition

      @Nonnull @CheckReturnValue ChannelAction<T> setPosition(@Nullable 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:
      IllegalArgumentException - If the provided position value is <0
    • setTopic

      @Nonnull @CheckReturnValue ChannelAction<T> setTopic(@Nullable String topic)
      Sets the topic for the channel
      Parameters:
      topic - The topic for the new GuildChannel
      Returns:
      The current ChannelAction, for chaining convenience
      Throws:
      UnsupportedOperationException - If this ChannelAction is not for a TextChannel
      IllegalArgumentException - If the provided topic is greater than 1024 in length. For IPostContainers, this limit is 4096 instead.
    • setNSFW

      @Nonnull @CheckReturnValue ChannelAction<T> setNSFW(boolean nsfw)
      Sets the NSFW flag for the channel
      Parameters:
      nsfw - The NSFW flag for the new GuildChannel
      Returns:
      The current ChannelAction, for chaining convenience
      Throws:
      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 channel. 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:
      UnsupportedOperationException - If this ChannelAction is not for a ISlowmodeChannel
      IllegalArgumentException - If the slowmode is greater than ISlowmodeChannel.MAX_SLOWMODE, or less than 0
    • setDefaultThreadSlowmode

      @Nonnull @CheckReturnValue ChannelAction<T> setDefaultThreadSlowmode(int slowmode)
      Sets the slowmode value, which limits the amount of time that individual users must wait between sending messages in the new channel. This is measured in seconds.
      This is applied to newly created threads by default.

      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:
      UnsupportedOperationException - If this ChannelAction is not for a IThreadContainer
      IllegalArgumentException - If the slowmode is greater than ISlowmodeChannel.MAX_SLOWMODE, or less than 0
    • setDefaultReaction

      @Nonnull @CheckReturnValue ChannelAction<T> setDefaultReaction(@Nullable Emoji emoji)
      Sets the default reaction emoji of the channel.
      This does not support custom emoji from other guilds.
      Parameters:
      emoji - The new default reaction emoji, or null to unset.
      Returns:
      The current ChannelAction, for chaining convenience
      See Also:
    • setDefaultLayout

      @Nonnull @CheckReturnValue ChannelAction<T> setDefaultLayout(@Nonnull ForumChannel.Layout layout)
      Sets the default layout of the new ForumChannel.
      Parameters:
      layout - The new default layout.
      Returns:
      The current ChannelAction, for chaining convenience
      Throws:
      IllegalArgumentException - If null or UNKNOWN is provided
      See Also:
    • setDefaultSortOrder

      @Nonnull @CheckReturnValue ChannelAction<T> setDefaultSortOrder(@Nonnull IPostContainer.SortOrder sortOrder)
      Sets the default sort order of the channel.
      Parameters:
      sortOrder - The new default sort order.
      Returns:
      The current ChannelAction, for chaining convenience
      Throws:
      IllegalArgumentException - If null or UNKNOWN is provided
      See Also:
    • setAvailableTags

      @Nonnull @CheckReturnValue ChannelAction<T> setAvailableTags(@Nonnull List<? extends BaseForumTag> tags)
      Sets the available tags of the channel.
      Tags will be ordered based on the provided list order.

      You can use ForumTagData to create new tags.

      Parameters:
      tags - The new available tags in the desired order.
      Returns:
      The current ChannelAction, for chaining convenience
      Throws:
      IllegalArgumentException - If the provided list is null or contains null elements
      See Also:
    • addPermissionOverride

      @Nonnull @CheckReturnValue default ChannelAction<T> addPermissionOverride(@Nonnull IPermissionHolder target, @Nullable Collection<Permission> allow, @Nullable 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.VIEW_CHANNEL);
      EnumSet<Permission> deny = EnumSet.of(Permission.MESSAGE_SEND);
      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.
      IllegalArgumentException - If the specified target is null or not within the same guild.
      See Also:
    • addPermissionOverride

      @Nonnull @CheckReturnValue default ChannelAction<T> addPermissionOverride(@Nonnull IPermissionHolder target, long allow, long 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();
      long allow = Permission.VIEW_CHANNEL.getRawValue();
      long deny = Permission.MESSAGE_SEND.getRawValue() | Permission.MESSAGE_ADD_REACTION.getRawValue();
      channelAction.addPermissionOverride(role, allow, deny);
      
      Parameters:
      target - The not-null Role or Member for the override
      allow - The granted Permissions for the override. Use Permission.getRawValue() to retrieve these Permissions.
      deny - The denied Permissions for the override. Use Permission.getRawValue() to retrieve these Permissions.
      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.
      IllegalArgumentException -
      • If the specified target is null or not within the same guild.
      • If one of the provided Permission values is invalid
      See Also:
    • addMemberPermissionOverride

      @Nonnull @CheckReturnValue default ChannelAction<T> addMemberPermissionOverride(long memberId, @Nullable Collection<Permission> allow, @Nullable 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.VIEW_CHANNEL);
      EnumSet<Permission> deny = EnumSet.of(Permission.MESSAGE_SEND);
      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:
    • addRolePermissionOverride

      @Nonnull @CheckReturnValue default ChannelAction<T> addRolePermissionOverride(long roleId, @Nullable Collection<Permission> allow, @Nullable 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.VIEW_CHANNEL);
      EnumSet<Permission> deny = EnumSet.of(Permission.MESSAGE_SEND);
      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:
    • addMemberPermissionOverride

      @Nonnull @CheckReturnValue ChannelAction<T> addMemberPermissionOverride(long memberId, long allow, long 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();
      long allow = Permission.VIEW_CHANNEL.getRawValue();
      long deny = Permission.MESSAGE_SEND.getRawValue() | Permission.MESSAGE_ADD_REACTION.getRawValue();
      channelAction.addMemberPermissionOverride(userId, allow, deny);
      
      Parameters:
      memberId - The id for the member
      allow - The granted Permissions for the override. Use Permission.getRawValue() to retrieve these Permissions.
      deny - The denied Permissions for the override. Use Permission.getRawValue() to retrieve these Permissions.
      Returns:
      The current ChannelAction, for chaining convenience
      Throws:
      IllegalArgumentException - If one of the provided Permission values is invalid
      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:
    • addRolePermissionOverride

      @Nonnull @CheckReturnValue ChannelAction<T> addRolePermissionOverride(long roleId, long allow, long 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();
      long allow = Permission.VIEW_CHANNEL.getRawValue();
      long deny = Permission.MESSAGE_SEND.getRawValue() | Permission.MESSAGE_ADD_REACTION.getRawValue();
      channelAction.addMemberPermissionOverride(roleId, allow, deny);
      
      Parameters:
      roleId - The id for the role
      allow - The granted Permissions for the override. Use Permission.getRawValue() to retrieve these Permissions.
      deny - The denied Permissions for the override. Use Permission.getRawValue() to retrieve these Permissions.
      Returns:
      The current ChannelAction, for chaining convenience
      Throws:
      IllegalArgumentException - If one of the provided Permission values is invalid
      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:
    • 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 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:
      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:
      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:
      IllegalArgumentException - If no parent has been configured. You have to use setParent(Category) before calling this method.
    • setBitrate

      @Nonnull @CheckReturnValue ChannelAction<T> setBitrate(@Nullable 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:
      UnsupportedOperationException - If this ChannelAction is not for a VoiceChannel
      IllegalArgumentException - If the provided bitrate is less than 8000 or greater than Guild.getMaxBitrate()
    • setUserlimit

      @Nonnull @CheckReturnValue ChannelAction<T> setUserlimit(@Nullable Integer userlimit)
      Sets the userlimit for the new AudioChannel.
      The limit maximum varies by type.
      Parameters:
      userlimit - The userlimit for the new AudioChannel or null/0 to use no limit
      Returns:
      The current ChannelAction, for chaining convenience
      Throws:
      UnsupportedOperationException - If this ChannelAction is not for a AudioChannel
      IllegalArgumentException - If the provided userlimit is negative or above the permitted limit
    • setRegion

      @Nonnull @CheckReturnValue ChannelAction<T> setRegion(@Nullable Region region)
      Sets the voice region for the new AudioChannel
      Parameters:
      region - The region for the new AudioChannel, or null to set to Region.AUTOMATIC
      Returns:
      The current ChannelAction, for chaining convenience
      Throws:
      UnsupportedOperationException - If this ChannelAction is not for an AudioChannel