Interface TextChannel

    • Field Detail

      • MAX_SLOWMODE

        static final int MAX_SLOWMODE
        The maximum duration of slowmode in seconds
        See Also:
        Constant Field Values
    • Method Detail

      • getTopic

        @Nullable
        java.lang.String getTopic()
        The topic set for this TextChannel.
        If no topic has been set, this returns null.
        Returns:
        Possibly-null String containing the topic of this TextChannel.
      • isNSFW

        boolean isNSFW()
        Whether or not this channel is considered as "NSFW" (Not-Safe-For-Work)
        Returns:
        True, If this TextChannel is considered NSFW by the official Discord Client
      • isNews

        boolean isNews()
        Whether or not this channel is considered an Announcement-/News-Channel.
        These channels can be used to crosspost messages to other guilds by using a follower type webhook.
        Returns:
        True, if this is considered a news channel
        Since:
        4.2.1
      • getSlowmode

        int getSlowmode()
        The slowmode set for this TextChannel.
        If slowmode is set this returns an int between 1 and TextChannel.MAX_SLOWMODE.
        If not set this returns 0.

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

        Returns:
        The slowmode for this TextChannel, between 1 and TextChannel.MAX_SLOWMODE, or 0 if no slowmode is set.
      • createCopy

        @Nonnull
        ChannelAction<TextChannel> createCopy​(@Nonnull
                                              Guild guild)
        Description copied from interface: GuildChannel
        Creates a copy of the specified GuildChannel in the specified Guild.
        If the provided target guild is not the same Guild this channel is in then the parent category and permissions will not be copied due to technical difficulty and ambiguity.

        This copies the following elements:

        1. Name
        2. Parent Category (if present)
        3. Voice Elements (Bitrate, Userlimit)
        4. Text Elements (Topic, NSFW, Slowmode)
        5. All permission overrides for Members/Roles

        Possible ErrorResponses caused by the returned RestAction include the following:

        Specified by:
        createCopy in interface GuildChannel
        Parameters:
        guild - The Guild to create the channel in
        Returns:
        A specific ChannelAction
        This action allows to set fields for the new GuildChannel before creating it!
      • retrieveWebhooks

        @Nonnull
        @CheckReturnValue
        RestAction<java.util.List<Webhook>> retrieveWebhooks()
        Retrieves the Webhooks attached to this TextChannel.

        Possible ErrorResponses include:

        Returns:
        RestAction - Type: List<Webhook>
        Retrieved an immutable list of Webhooks attached to this channel
      • createWebhook

        @Nonnull
        @CheckReturnValue
        WebhookAction createWebhook​(@Nonnull
                                    java.lang.String name)
        Creates a new Webhook.

        Possible ErrorResponses caused by the returned RestAction include the following:

        Parameters:
        name - The default name for the new Webhook.
        Returns:
        A specific WebhookAction
        This action allows to set fields for the new webhook before creating it
        Throws:
        PermissionException - If you do not hold the permission Manage Webhooks
        java.lang.IllegalArgumentException - If the provided name is null, blank or not between 2-100 characters in length
      • follow

        @Nonnull
        @CheckReturnValue
        RestAction<Webhook.WebhookReference> follow​(@Nonnull
                                                    java.lang.String targetChannelId)
        Subscribes to the crossposted messages in this channel.
        This will create a Webhook of type FOLLOWER in the target channel.

        Possible ErrorResponses include:

        Parameters:
        targetChannelId - The target channel id
        Returns:
        RestAction
        Throws:
        java.lang.IllegalArgumentException - If null is provided
        java.lang.IllegalStateException - If this is not a news channels (See isNews())
        Since:
        4.2.1
      • clearReactionsById

        @Nonnull
        @CheckReturnValue
        RestAction<java.lang.Void> clearReactionsById​(@Nonnull
                                                      java.lang.String messageId)
        Attempts to remove all reactions from a message with the specified messageId in this TextChannel
        This is useful for moderator commands that wish to remove all reactions at once from a specific message.

        The following ErrorResponses are possible:

        Parameters:
        messageId - The not-empty valid message id
        Returns:
        AuditableRestAction
        Throws:
        InsufficientPermissionException - If the currently logged in account does not have Permission.MESSAGE_MANAGE in this channel.
        java.lang.IllegalArgumentException - If the provided id is null or empty.
      • clearReactionsById

        @Nonnull
        @CheckReturnValue
        RestAction<java.lang.Void> clearReactionsById​(@Nonnull
                                                      java.lang.String messageId,
                                                      @Nonnull
                                                      java.lang.String unicode)
        Removes all reactions for the specified emoji.

        Example

        
         // custom
         channel.clearReactions(messageId, "minn:245267426227388416").queue();
         // unicode escape
         channel.clearReactions(messageId, "\uD83D\uDE02").queue();
         // codepoint notation
         channel.clearReactions(messageId, "U+1F602").queue();
         

        The following ErrorResponses are possible:

        • MISSING_ACCESS
          The currently logged in account lost access to the channel by either being removed from the guild or losing the VIEW_CHANNEL permission
        • UNKNOWN_EMOJI
          The provided unicode emoji doesn't exist. Try using one of the example formats.
        • UNKNOWN_MESSAGE
          The message was deleted.
        Parameters:
        messageId - The id for the target message
        unicode - The unicode emoji to remove reactions for
        Returns:
        RestAction
        Throws:
        InsufficientPermissionException - If the currently logged in account does not have Permission.MESSAGE_MANAGE in the channel
        java.lang.IllegalArgumentException - If provided with null
        Since:
        4.2.0
      • clearReactionsById

        @Nonnull
        @CheckReturnValue
        RestAction<java.lang.Void> clearReactionsById​(@Nonnull
                                                      java.lang.String messageId,
                                                      @Nonnull
                                                      Emote emote)
        Removes all reactions for the specified emoji.

        The following ErrorResponses are possible:

        Parameters:
        messageId - The id for the target message
        emote - The Emote to remove reactions for
        Returns:
        RestAction
        Throws:
        InsufficientPermissionException - If the currently logged in account does not have Permission.MESSAGE_MANAGE in the channel
        java.lang.IllegalArgumentException - If provided with null
        Since:
        4.2.0
      • clearReactionsById

        @Nonnull
        @CheckReturnValue
        default RestAction<java.lang.Void> clearReactionsById​(long messageId,
                                                              @Nonnull
                                                              java.lang.String unicode)
        Removes all reactions for the specified emoji.

        Example

        
         // custom
         channel.clearReactions(messageId, "minn:245267426227388416").queue();
         // unicode escape
         channel.clearReactions(messageId, "\uD83D\uDE02").queue();
         // codepoint notation
         channel.clearReactions(messageId, "U+1F602").queue();
         

        The following ErrorResponses are possible:

        • MISSING_ACCESS
          The currently logged in account lost access to the channel by either being removed from the guild or losing the VIEW_CHANNEL permission
        • UNKNOWN_EMOJI
          The provided unicode emoji doesn't exist. Try using one of the example formats.
        • UNKNOWN_MESSAGE
          The message was deleted.
        Parameters:
        messageId - The id for the target message
        unicode - The unicode emoji to remove reactions for
        Returns:
        RestAction
        Throws:
        InsufficientPermissionException - If the currently logged in account does not have Permission.MESSAGE_MANAGE in the channel
        java.lang.IllegalArgumentException - If provided with null
        Since:
        4.2.0
      • clearReactionsById

        @Nonnull
        @CheckReturnValue
        default RestAction<java.lang.Void> clearReactionsById​(long messageId,
                                                              @Nonnull
                                                              Emote emote)
        Removes all reactions for the specified emoji.

        The following ErrorResponses are possible:

        Parameters:
        messageId - The id for the target message
        emote - The Emote to remove reactions for
        Returns:
        RestAction
        Throws:
        InsufficientPermissionException - If the currently logged in account does not have Permission.MESSAGE_MANAGE in the channel
        java.lang.IllegalArgumentException - If provided with null
        Since:
        4.2.0
      • removeReactionById

        @Nonnull
        @CheckReturnValue
        RestAction<java.lang.Void> removeReactionById​(@Nonnull
                                                      java.lang.String messageId,
                                                      @Nonnull
                                                      java.lang.String unicode,
                                                      @Nonnull
                                                      User user)
        Attempts to remove the reaction from a message represented by the specified messageId in this MessageChannel.

        The unicode provided has to be a unicode representation of the emoji that is supposed to be represented by the Reaction.
        To retrieve the characters needed you can use an api or the official discord client by escaping the emoji (\:emoji-name:) and copying the resulting emoji from the sent message.

        This method encodes the provided unicode for you. Do not encode the emoji before providing the unicode.

        The following ErrorResponses are possible:

        Parameters:
        messageId - The messageId to remove the reaction from
        unicode - The unicode characters of the emoji
        user - The target user of which to remove from
        Returns:
        RestAction
        Throws:
        java.lang.IllegalArgumentException -
        • If provided messageId is null or empty.
        • If provided unicode is null or empty.
        InsufficientPermissionException - If the currently logged in account does not have Permission.MESSAGE_MANAGE in this channel.
      • removeReactionById

        @Nonnull
        @CheckReturnValue
        default RestAction<java.lang.Void> removeReactionById​(long messageId,
                                                              @Nonnull
                                                              java.lang.String unicode,
                                                              @Nonnull
                                                              User user)
        Attempts to remove the reaction from a message represented by the specified messageId in this MessageChannel.

        The unicode provided has to be a unicode representation of the emoji that is supposed to be represented by the Reaction.
        To retrieve the characters needed you can use an api or the official discord client by escaping the emoji (\:emoji-name:) and copying the resulting emoji from the sent message.

        This method encodes the provided unicode for you. Do not encode the emoji before providing the unicode.

        The following ErrorResponses are possible:

        Parameters:
        messageId - The messageId to remove the reaction from
        unicode - The unicode characters of the emoji
        user - The target user of which to remove from
        Returns:
        RestAction
        Throws:
        java.lang.IllegalArgumentException -
        • If provided messageId is null or empty.
        • If provided unicode is null or empty.
        InsufficientPermissionException - If the currently logged in account does not have Permission.MESSAGE_MANAGE in this channel.
      • removeReactionById

        @Nonnull
        @CheckReturnValue
        default RestAction<java.lang.Void> removeReactionById​(@Nonnull
                                                              java.lang.String messageId,
                                                              @Nonnull
                                                              Emote emote,
                                                              @Nonnull
                                                              User user)
        Attempts to remove the reaction from a message represented by the specified messageId in this MessageChannel.

        An Emote is not the same as an emoji!
        Emotes are custom guild-specific images unlike global unicode emojis!

        The following ErrorResponses are possible:

        Parameters:
        messageId - The messageId to remove the reaction from
        emote - The emote to remove
        user - The target user of which to remove from
        Returns:
        RestAction
        Throws:
        java.lang.IllegalArgumentException -
        • If provided messageId is null or empty.
        • If provided emote is null.
        InsufficientPermissionException - If the currently logged in account does not have Permission.MESSAGE_MANAGE in this channel.
      • removeReactionById

        @Nonnull
        @CheckReturnValue
        default RestAction<java.lang.Void> removeReactionById​(long messageId,
                                                              @Nonnull
                                                              Emote emote,
                                                              @Nonnull
                                                              User user)
        Attempts to remove the reaction from a message represented by the specified messageId in this MessageChannel.

        An Emote is not the same as an emoji!
        Emotes are custom guild-specific images unlike global unicode emojis!

        The following ErrorResponses are possible:

        Parameters:
        messageId - The messageId to remove the reaction from
        emote - The emote to remove
        user - The target user of which to remove from
        Returns:
        RestAction
        Throws:
        java.lang.IllegalArgumentException -
        • If provided messageId is null or empty.
        • If provided emote is null.
        InsufficientPermissionException - If the currently logged in account does not have Permission.MESSAGE_MANAGE in this channel.
      • canTalk

        boolean canTalk​(@Nonnull
                        Member member)
        Whether the specified Member can send messages in this channel.
        Checks for both Permission.MESSAGE_READ and Permission.MESSAGE_WRITE.
        Parameters:
        member - The Member to check
        Returns:
        True, if the specified member is able to read and send messages in this channel
      • formatTo

        default void formatTo​(java.util.Formatter formatter,
                              int flags,
                              int width,
                              int precision)
        Specified by:
        formatTo in interface java.util.Formattable
        Specified by:
        formatTo in interface IMentionable
        Specified by:
        formatTo in interface MessageChannel