Class WebhookMessageBuilder

    • Constructor Detail

      • WebhookMessageBuilder

        public WebhookMessageBuilder()
    • Method Detail

      • isEmpty

        public boolean isEmpty()
        Whether this builder is currently empty
        Returns:
        True, if this builder is empty
      • getFileAmount

        public int getFileAmount()
        The amount of files currently added
        Returns:
        The amount of currently added files
      • reset

        @NotNull
        public @NotNull WebhookMessageBuilder reset()
        Clears this builder to its default state
        Returns:
        This builder for chaining convenience
      • resetFiles

        @NotNull
        public @NotNull WebhookMessageBuilder resetFiles()
        Clears all files currently added to this builder
        Returns:
        This builder for chaining convenience
      • resetEmbeds

        @NotNull
        public @NotNull WebhookMessageBuilder resetEmbeds()
        Clears all embeds currently added this builder
        Returns:
        This builder for chaining convenience
      • setContent

        @NotNull
        public @NotNull WebhookMessageBuilder setContent​(@Nullable
                                                         @Nullable String content)
        Configures the content for this builder
        Parameters:
        content - The (nullable) content to use
        Returns:
        This builder for chaining convenience
        Throws:
        IllegalArgumentException - If the content is larger than 2000 characters
      • append

        @NotNull
        public @NotNull WebhookMessageBuilder append​(@NotNull
                                                     @NotNull String content)
        Appends the provided content to the already present content in this message.
        Parameters:
        content - The content to append
        Returns:
        This builder for chaining convenience
        Throws:
        NullPointerException - If provided with null
        IllegalArgumentException - If the content exceeds 2000 characters
      • setUsername

        @NotNull
        public @NotNull WebhookMessageBuilder setUsername​(@Nullable
                                                          @Nullable String username)
        The username to use for this message.
        Each message by a webhook can have a different user appearance. If this is not set it will default the user appearance in the settings of the webhook.
        Parameters:
        username - The (nullable) username to use
        Returns:
        This builder for chaining convenience
      • setAvatarUrl

        @NotNull
        public @NotNull WebhookMessageBuilder setAvatarUrl​(@Nullable
                                                           @Nullable String avatarUrl)
        The avatar url to use for this message.
        Each message by a webhook can have a different user appearance. If this is not set it will default the user appearance in the settings of the webhook.
        Parameters:
        avatarUrl - The (nullable) avatar url to use
        Returns:
        This builder for chaining convenience
      • setTTS

        @NotNull
        public @NotNull WebhookMessageBuilder setTTS​(boolean tts)
        Whether this message should use Text-to-Speech (TTS)
        Parameters:
        tts - True, if this message should use tts
        Returns:
        This builder for chaining convenience
      • setEphemeral

        @NotNull
        public @NotNull WebhookMessageBuilder setEphemeral​(boolean ephemeral)
        Whether the message should be ephemeral (only works for interaction webhooks).
        Parameters:
        ephemeral - True if the message should be ephemeral, false otherwise
        Returns:
        This builder for chaining convenience
      • addFile

        @NotNull
        public @NotNull WebhookMessageBuilder addFile​(@NotNull
                                                      @NotNull File file)
        Adds the provided file as an attachment to this message.
        A single message can have up to 10 attachments.
        Parameters:
        file - The file to attach
        Returns:
        This builder for chaining convenience
        Throws:
        NullPointerException - If provided with null
      • addFile

        @NotNull
        public @NotNull WebhookMessageBuilder addFile​(@NotNull
                                                      @NotNull String name,
                                                      @NotNull
                                                      @NotNull File file)
        Adds the provided file as an attachment to this message.
        A single message can have up to 10 attachments.
        Parameters:
        name - The alternative name that should be used instead
        file - The file to attach
        Returns:
        This builder for chaining convenience
        Throws:
        NullPointerException - If provided with null
      • addFile

        @NotNull
        public @NotNull WebhookMessageBuilder addFile​(@NotNull
                                                      @NotNull String name,
                                                      @NotNull
                                                      @org.jetbrains.annotations.NotNull byte[] data)
        Adds the provided data as a file attachment to this message.
        A single message can have up to 10 attachments.
        Parameters:
        name - The alternative name that should be used
        data - The data to attach as a file
        Returns:
        This builder for chaining convenience
        Throws:
        NullPointerException - If provided with null
      • addFile

        @NotNull
        public @NotNull WebhookMessageBuilder addFile​(@NotNull
                                                      @NotNull String name,
                                                      @NotNull
                                                      @NotNull InputStream data)
        Adds the provided data as a file attachment to this message.
        A single message can have up to 10 attachments.
        Parameters:
        name - The alternative name that should be used
        data - The data to attach as a file
        Returns:
        This builder for chaining convenience
        Throws:
        NullPointerException - If provided with null
      • setThreadName

        @NotNull
        public @NotNull WebhookMessageBuilder setThreadName​(@Nullable
                                                            @Nullable String name)
        Sets the provided name as the name for a newly created thread.
        This is only valid for forum/media channels.
        Parameters:
        name - The name that should be used
        Returns:
        This builder for chaining convenience
      • fromJDA

        @NotNull
        public static @NotNull WebhookMessageBuilder fromJDA​(@NotNull
                                                             net.dv8tion.jda.api.entities.Message message)
        Converts a JDA Message into a compatible WebhookMessageBuilder.
        Parameters:
        message - The message
        Returns:
        WebhookMessageBuilder with the converted data
        Throws:
        NullPointerException - If null is provided
      • fromJDA

        @NotNull
        public static @NotNull WebhookMessageBuilder fromJDA​(@NotNull
                                                             @NotNull net.dv8tion.jda.api.utils.messages.MessageCreateData message)
        Converts a JDA Message into a compatible WebhookMessageBuilder.
        Parameters:
        message - The message
        Returns:
        WebhookMessageBuilder with the converted data
        Throws:
        NullPointerException - If null is provided
      • fromJavacord

        @NotNull
        public static @NotNull WebhookMessageBuilder fromJavacord​(@NotNull
                                                                  org.javacord.api.entity.message.Message message)
        Converts a Javacord Message into a compatible WebhookMessageBuilder.
        Parameters:
        message - The message
        Returns:
        WebhookMessageBuilder with the converted data
        Throws:
        NullPointerException - If null is provided
      • fromD4J

        @NotNull
        @Deprecated
        public static @NotNull WebhookMessageBuilder fromD4J​(@NotNull
                                                             @NotNull Consumer<? super discord4j.core.spec.MessageCreateSpec> callback)
        Deprecated.
        Converts a Discord4J MessageCreateSpec into a compatible WebhookMessageBuilder.
        Parameters:
        callback - The callback used to specify the desired message settings
        Returns:
        WebhookMessageBuilder with the converted data
        Throws:
        NullPointerException - If null is provided
      • fromD4J

        @NotNull
        public static @NotNull WebhookMessageBuilder fromD4J​(@NotNull
                                                             @NotNull discord4j.core.spec.MessageCreateSpec spec)
        Converts a Discord4J MessageCreateSpec into a compatible WebhookMessageBuilder.
        Parameters:
        spec - The message create spec used to specify the desired message settings
        Returns:
        WebhookMessageBuilder with the converted data
        Throws:
        NullPointerException - If null is provided
      • fromD4J

        @NotNull
        public static @NotNull WebhookMessageBuilder fromD4J​(@NotNull
                                                             @NotNull discord4j.core.spec.MessageEditSpec spec)
        Converts a Discord4J MessageCreateSpec into a compatible WebhookMessageBuilder.
        Parameters:
        spec - The message create spec used to specify the desired message settings
        Returns:
        WebhookMessageBuilder with the converted data
        Throws:
        NullPointerException - If null is provided