Interface Message

All Superinterfaces:
Formattable, ISnowflake

public interface Message extends ISnowflake, Formattable
Represents a Text message received from Discord.
This represents messages received from MessageChannels.

This type is not updated. JDA does not keep track of changes to messages, it is advised to do this via events such as MessageUpdateEvent and similar.

Message Differences

There are 3 implementations of this interface in JDA.
  1. Received Message
    Messages received through events or history query. These messages hold information of existing messages and can be modified or deleted.
  2. System Message
    Specification of Received Messages that are generated by Discord on certain events. Commonly this is used in groups or to indicate a pin within a MessageChannel. The different types can be found in the MessageType enum.
  3. Data Message
    This type is produced by MessageBuilder and only holds sendable information such as content or nonce. These messages do not allow any modifications via RestActions or information that is generated when sent such as the id to be used.

When a feature is not available it will throw an UnsupportedOperationException as per interface specifications.
Specific operations may have specified information available in the throws javadoc.

Formattable

This interface extends Formattable and can be used with a Formatter such as used by String.format(String, Object...) or PrintStream.printf(String, Object...).

This will use getContentDisplay() rather than Object.toString()!
Supported Features:

  • Alternative
    - Using getContentRaw() (Example: %#s - uses getContentDisplay())
  • Width/Left-Justification
    - Ensures the size of a format (Example: %20s - uses at minimum 20 chars; %-10s - uses left-justified padding)
  • Precision
    - Cuts the content to the specified size (replacing last 3 chars with ...; Example: %.20s)

More information on formatting syntax can be found in the format syntax documentation!

See Also: