Class MessageReceivedEvent

  • All Implemented Interfaces:
    GenericEvent

    public class MessageReceivedEvent
    extends GenericMessageEvent
    Indicates that a Message was received in a MessageChannel.
    This includes TextChannel and PrivateChannel!

    Can be used to detect that a Message is received in either a guild- or private channel. Providing a MessageChannel and Message.

    Requirements

    This event requires at least one of the following intents (Will not fire at all if neither is enabled):

    • Constructor Detail

      • MessageReceivedEvent

        public MessageReceivedEvent​(@Nonnull
                                    JDA api,
                                    long responseNumber,
                                    @Nonnull
                                    Message message)
    • Method Detail

      • getMessage

        @Nonnull
        public Message getMessage()
        The received Message object.
        Returns:
        The received Message object.
      • getAuthor

        @Nonnull
        public User getAuthor()
        The Author of the Message received as User object.
        This will be never-null but might be a fake user if Message was sent via Webhook (Guild only). See Webhook.getDefaultUser().
        Returns:
        The Author of the Message.
        See Also:
        isWebhookMessage()
      • isWebhookMessage

        public boolean isWebhookMessage()
        Whether or not the Message received was sent via a Webhook.
        This is a shortcut for getMessage().isWebhookMessage().
        Returns:
        True, if the Message was sent via Webhook