Class MessageReceivedEvent
- java.lang.Object
-
- net.dv8tion.jda.api.events.Event
-
- net.dv8tion.jda.api.events.message.GenericMessageEvent
-
- net.dv8tion.jda.api.events.message.MessageReceivedEvent
-
- All Implemented Interfaces:
GenericEvent
public class MessageReceivedEvent extends GenericMessageEvent
Indicates that a Message was received in aMessageChannel
.
This includesTextChannel
andPrivateChannel
!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):
GUILD_MESSAGES
to work in guild text channelsDIRECT_MESSAGES
to work in private channels
-
-
Constructor Summary
Constructors Constructor Description MessageReceivedEvent(JDA api, long responseNumber, Message message)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description User
getAuthor()
The Author of the Message received asUser
object.Member
getMember()
The Author of the Message received asMember
object.Message
getMessage()
The receivedMessage
object.boolean
isWebhookMessage()
Whether or not the Message received was sent via a Webhook.-
Methods inherited from class net.dv8tion.jda.api.events.message.GenericMessageEvent
getChannel, getChannelType, getGuild, getMessageId, getMessageIdLong, getPrivateChannel, getTextChannel, isFromGuild, isFromType
-
Methods inherited from class net.dv8tion.jda.api.events.Event
getJDA, getResponseNumber
-
-
-
-
Method Detail
-
getMessage
@Nonnull public Message getMessage()
The receivedMessage
object.- Returns:
- The received
Message
object.
-
getAuthor
@Nonnull public User getAuthor()
The Author of the Message received asUser
object.
This will be never-null but might be a fake user if Message was sent via Webhook (Guild only). SeeWebhook.getDefaultUser()
.- Returns:
- The Author of the Message.
- See Also:
isWebhookMessage()
-
getMember
@Nullable public Member getMember()
The Author of the Message received asMember
object.
This will benull
in case of Message being received in aPrivateChannel
orisWebhookMessage()
returningtrue
.- Returns:
- The Author of the Message as null-able Member object.
- See Also:
isWebhookMessage()
-
isWebhookMessage
public boolean isWebhookMessage()
Whether or not the Message received was sent via a Webhook.
This is a shortcut forgetMessage().isWebhookMessage()
.- Returns:
- True, if the Message was sent via Webhook
-
-