Class GuildMessageReceivedEvent

  • All Implemented Interfaces:
    GenericEvent

    public class GuildMessageReceivedEvent
    extends GenericGuildMessageEvent
    Indicates that a Message is received in a TextChannel.

    Can be used to retrieve the affected TextChannel and Message.

    Requirements

    This event requires the GUILD_MESSAGES intent to be enabled.

    • Constructor Detail

      • GuildMessageReceivedEvent

        public GuildMessageReceivedEvent​(@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. See Webhook.getDefaultUser().
        Returns:
        The Author of the Message.
        See Also:
        isWebhookMessage()
      • getMember

        @Nullable
        public Member getMember()
        The Author of the Message received as Member object.
        This will be null in case of isWebhookMessage() returning true.
        Returns:
        The Author of the Message as Member object.
        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:
        Whether or not the Message was sent via Webhook