Class GenericMessageEvent

java.lang.Object
net.dv8tion.jda.api.events.Event
net.dv8tion.jda.api.events.message.GenericMessageEvent
All Implemented Interfaces:
GenericEvent
Direct Known Subclasses:
GenericMessagePollVoteEvent, GenericMessageReactionEvent, MessageDeleteEvent, MessageReactionRemoveAllEvent, MessageReactionRemoveEmojiEvent, MessageReceivedEvent, MessageUpdateEvent

public abstract class GenericMessageEvent extends Event
Indicates that a Message was created/deleted/changed.
Every MessageEvent is an instance of this event and can be casted.

Can be used to detect any MessageEvent.

Requirements

These events require at least one of the following intents (Will not fire at all if neither is enabled):

  • Constructor Details

    • GenericMessageEvent

      public GenericMessageEvent(@Nonnull JDA api, long responseNumber, long messageId, @Nonnull MessageChannel channel)
  • Method Details

    • getChannel

      @Nonnull public MessageChannelUnion getChannel()
      The MessageChannel for this Message
      Returns:
      The MessageChannel
    • getGuildChannel

      @Nonnull public GuildMessageChannelUnion getGuildChannel()
      The GuildMessageChannel for this Message if it was sent in a Guild.
      If this Message was not received from a Guild, this will throw an IllegalStateException.
      Returns:
      The GuildMessageChannel
      Throws:
      IllegalStateException - If this was not sent in a channel in a Guild.
    • getMessageId

      @Nonnull public String getMessageId()
      The id for this message
      Returns:
      The id for this message
    • getMessageIdLong

      public long getMessageIdLong()
      The id for this message
      Returns:
      The id for this message
    • isFromType

      public boolean isFromType(@Nonnull ChannelType type)
      Indicates whether the message is from the specified ChannelType
      Parameters:
      type - The ChannelType
      Returns:
      True, if the message is from the specified channel type
    • isFromGuild

      public boolean isFromGuild()
      Whether this message was sent in a Guild.
      If this is false then getGuild() will throw an IllegalStateException.
      Returns:
      True, if getChannelType().isGuild() is true.
    • getChannelType

      @Nonnull public ChannelType getChannelType()
      The ChannelType for this message
      Returns:
      The ChannelType
    • getGuild

      @Nonnull public Guild getGuild()
      The Guild the Message was received in.
      If this Message was not received in a Guild, this will throw an IllegalStateException.
      Returns:
      The Guild the Message was received in
      Throws:
      IllegalStateException - If this was not sent in a GuildChannel.
      See Also:
    • getJumpUrl

      @Nonnull public String getJumpUrl()
      Returns the jump-to URL for the received message.
      Clicking this URL in the Discord client will cause the client to jump to the specified message.
      Returns:
      A String representing the jump-to URL for the message
    • isFromThread

      public boolean isFromThread()
      If the message event was from a ThreadChannel
      Returns:
      If the message event was from a ThreadChannel
      See Also: