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
Indicates that a
Every MessageEvent is an instance of this event and can be casted.
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):
GUILD_MESSAGESto work in guild text channelsDIRECT_MESSAGESto work in private channels
-
Constructor Summary
ConstructorsConstructorDescriptionGenericMessageEvent(JDA api, long responseNumber, long messageId, MessageChannel channel) -
Method Summary
Modifier and TypeMethodDescriptionTheMessageChannelfor this MessageTheChannelTypefor this messagegetGuild()TheGuildthe Message was received in.TheGuildMessageChannelfor this Message if it was sent in a Guild.Returns the jump-to URL for the received message.The id for this messagelongThe id for this messagebooleanWhether this message was sent in aGuild.booleanIf the message event was from aThreadChannelbooleanisFromType(ChannelType type) Indicates whether the message is from the specifiedChannelTypeMethods inherited from class net.dv8tion.jda.api.events.Event
getJDA, getRawData, getResponseNumber, toString
-
Constructor Details
-
GenericMessageEvent
public GenericMessageEvent(@Nonnull JDA api, long responseNumber, long messageId, @Nonnull MessageChannel channel)
-
-
Method Details
-
getChannel
TheMessageChannelfor this Message- Returns:
- The MessageChannel
-
getGuildChannel
TheGuildMessageChannelfor this Message if it was sent in a Guild.
If this Message was not received from aGuild, this will throw anIllegalStateException.- Returns:
- The GuildMessageChannel
- Throws:
IllegalStateException- If this was not sent in a channel in a Guild.
-
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
Indicates whether the message is from the specifiedChannelType- 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 aGuild.
If this isfalsethengetGuild()will throw anIllegalStateException.- Returns:
- True, if
getChannelType().isGuild()is true.
-
getChannelType
TheChannelTypefor this message- Returns:
- The ChannelType
-
getGuild
TheGuildthe Message was received in.
If this Message was not received in aGuild, this will throw anIllegalStateException.- Returns:
- The Guild the Message was received in
- Throws:
IllegalStateException- If this was not sent in aGuildChannel.- See Also:
-
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 aThreadChannel- Returns:
- If the message event was from a ThreadChannel
- See Also:
-