Class WebhookMessage

    • Field Detail

      • MAX_FILES

        public static final int MAX_FILES
        Maximum amount of files a single message can hold (10)
        See Also:
        Constant Field Values
      • MAX_EMBEDS

        public static final int MAX_EMBEDS
        Maximum amount of embeds a single message can hold (10)
        See Also:
        Constant Field Values
    • Method Detail

      • getUsername

        @Nullable
        public @Nullable String getUsername()
        The username for this message
        Returns:
        Possibly-null username
      • getAvatarUrl

        @Nullable
        public @Nullable String getAvatarUrl()
        The avatar url for this message
        Returns:
        Possibly-null avatar url
      • getContent

        @Nullable
        public @Nullable String getContent()
        The content for this message
        Returns:
        Possibly-null content
      • getEmbeds

        @NotNull
        public @NotNull List<WebhookEmbed> getEmbeds()
        The embeds for this message
        Returns:
        The embeds
      • getAttachments

        @Nullable
        public @Nullable MessageAttachment[] getAttachments()
        The attachments for this message
        Returns:
        The attachments
      • isTTS

        public boolean isTTS()
        Whether this message should use Text-to-Speech (TTS)
        Returns:
        True, if this message will use tts
      • getFlags

        public int getFlags()
        The message flags used for this message.
        Returns:
        The flags
      • asEphemeral

        @NotNull
        public @NotNull WebhookMessage asEphemeral​(boolean ephemeral)
        Returns a new WebhookMessage instance with the ephemeral flag turned on/off (true/false).
        This instance remains unchanged and a new instance is returned.
        Parameters:
        ephemeral - Whether to make this message ephemeral
        Returns:
        New WebhookMessage instance
      • embeds

        @NotNull
        public static @NotNull WebhookMessage embeds​(@NotNull
                                                     @NotNull WebhookEmbed first,
                                                     @NotNull
                                                     @NotNull WebhookEmbed... embeds)
        Creates a WebhookMessage from the provided embeds. A message can hold up to 10 embeds.
        Parameters:
        first - The first embed
        embeds - Optional additional embeds for the message
        Returns:
        A WebhookMessage for the embeds
        Throws:
        NullPointerException - If provided with null
        IllegalArgumentException - If more than 10 are provided
      • files

        @NotNull
        public static @NotNull WebhookMessage files​(@NotNull
                                                    @NotNull Map<String,​?> attachments)
        Creates a WebhookMessage from the provided attachments.
        A message can hold up to 10 attachments and a total of 8MiB of data.
        Parameters:
        attachments - The attachments to add, keys are the alternative names for each attachment
        Returns:
        A WebhookMessage for the attachments
        Throws:
        NullPointerException - If provided with null
        IllegalArgumentException - If no attachments are provided or more than 10
      • files

        @NotNull
        public static @NotNull WebhookMessage files​(@NotNull
                                                    @NotNull String name1,
                                                    @NotNull
                                                    @NotNull Object data1,
                                                    @NotNull
                                                    @NotNull Object... attachments)
        Creates a WebhookMessage from the provided attachments.
        A message can hold up to 10 attachments and a total of 8MiB of data.

        The files are provided in pairs of Name->Data similar to the first 2 arguments.
        The allowed data types are byte[] | InputStream | File

        Parameters:
        name1 - The alternative name of the first attachment
        data1 - The first attachment, must be of type byte[] | InputStream | File
        attachments - Optional additional attachments to add, pairs of String->Data
        Returns:
        A WebhookMessage for the attachments
        Throws:
        NullPointerException - If provided with null
        IllegalArgumentException - If no attachments are provided or more than 10 or the additional arguments are not an even count or an invalid format
      • isFile

        public boolean isFile()
        Whether this message contains files
        Returns:
        True, if this message contains files
      • getBody

        @NotNull
        public @NotNull RequestBody getBody()
        Provides a RequestBody of this message.
        This is used internally for executing webhooks through HTTP requests.
        Returns:
        The request body