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 includesTextChannelandPrivateChannel!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_MESSAGESto work in guild text channelsDIRECT_MESSAGESto 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 UsergetAuthor()The Author of the Message received asUserobject.MembergetMember()The Author of the Message received asMemberobject.MessagegetMessage()The receivedMessageobject.booleanisWebhookMessage()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 receivedMessageobject.- Returns:
- The received
Messageobject.
-
getAuthor
@Nonnull public User getAuthor()
The Author of the Message received asUserobject.
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 asMemberobject.
This will benullin case of Message being received in aPrivateChannelorisWebhookMessage()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
-
-