Package net.dv8tion.jda.api.entities
Class MessageReference
java.lang.Object
net.dv8tion.jda.api.entities.MessageReference
An object representing a reference in a Discord message.
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
The type of message reference -
Constructor Summary
ConstructorDescriptionMessageReference
(int type, long messageId, long channelId, long guildId, Message referencedMessage, JDA api) -
Method Summary
Modifier and TypeMethodDescriptionThe channel from which this message originates.Returns the channel id for this reference, or 0 if no channel id was provided.long
Returns the channel id for this reference, or 0 if no channel id was provided.getGuild()
The guild for this reference.Returns the guild id for this reference, or 0 if no guild id was provided.long
Returns the guild id for this reference, or 0 if no guild id was provided.getJDA()
Returns the JDA instance related to this message reference.The resolved message, if available.Returns the message id for this reference, or 0 if no message id was provided.long
Returns the message id for this reference, or 0 if no message id was provided.getType()
The type of this message referenceint
The message reference type idresolve()
Retrieves the referenced message for this message.resolve
(boolean update) Retrieves the referenced message for this message.
-
Constructor Details
-
MessageReference
-
-
Method Details
-
resolve
Retrieves the referenced message for this message.
If the message already exists, it will be returned immediately.The following
ErrorResponses
are possible:MISSING_ACCESS
The request was attempted after the account lost access to theGuild
typically due to being kicked or removed, or afterPermission.VIEW_CHANNEL
was revoked in theTextChannel
MISSING_PERMISSIONS
The request was attempted after the account lostPermission.MESSAGE_HISTORY
in theTextChannel
.UNKNOWN_MESSAGE
The message has already been deleted.UNKNOWN_CHANNEL
The request was attempted after the channel was deleted.
- Returns:
RestAction
- Type:Message
- Throws:
InsufficientPermissionException
- If this reference refers to aGuildChannel
and the logged in account does not havePermission.VIEW_CHANNEL
Permission.VOICE_CONNECT
(applicable ifgetChannel().getType().isAudio()
)Permission.MESSAGE_HISTORY
IllegalStateException
- If this message reference does not have a channel
-
resolve
Retrieves the referenced message for this message.
If the message already exists, it will be returned immediately.The following
ErrorResponses
are possible:MISSING_ACCESS
The request was attempted after the account lost access to theGuild
typically due to being kicked or removed, or afterPermission.VIEW_CHANNEL
was revoked in theTextChannel
MISSING_PERMISSIONS
The request was attempted after the account lostPermission.MESSAGE_HISTORY
in theTextChannel
.UNKNOWN_MESSAGE
The message has already been deleted.UNKNOWN_CHANNEL
The request was attempted after the channel was deleted.
- Parameters:
update
- Whether to update the already stored message- Returns:
RestAction
- Type:Message
- Throws:
InsufficientPermissionException
- If this reference refers to aGuildChannel
and the logged in account does not havePermission.VIEW_CHANNEL
Permission.VOICE_CONNECT
(applicable ifgetChannel().getType().isAudio()
)Permission.MESSAGE_HISTORY
IllegalStateException
- If this message reference does not have a channel
-
getMessage
The resolved message, if available.This will have different meaning depending on the
type
of message. Usually, this is aINLINE_REPLY
reference. This can be null even if the type isINLINE_REPLY
, when the message it references doesn't exist or discord wasn't able to resolve it in time.- Returns:
- The referenced message, or null if this is not available
- See Also:
-
getChannel
The channel from which this message originates.
Messages from other guilds can be referenced, in which case JDA may not have the channel cached.- Returns:
- The origin channel for this message reference, or null if this is not available
- See Also:
-
getGuild
The guild for this reference.
This will be null if the message did not come from a guild, the guild was not provided, or JDA did not have the guild cached- Returns:
- The guild, or null if this is not available
- See Also:
-
getTypeRaw
public int getTypeRaw()The message reference type id- Returns:
- The raw type id
-
getType
The type of this message reference -
getMessageIdLong
public long getMessageIdLong()Returns the message id for this reference, or 0 if no message id was provided.- Returns:
- The message id, or 0.
-
getChannelIdLong
public long getChannelIdLong()Returns the channel id for this reference, or 0 if no channel id was provided.- Returns:
- The channel id, or 0.
-
getGuildIdLong
public long getGuildIdLong()Returns the guild id for this reference, or 0 if no guild id was provided.- Returns:
- The guild id, or 0.
-
getMessageId
Returns the message id for this reference, or 0 if no message id was provided.- Returns:
- The message id, or 0.
-
getChannelId
Returns the channel id for this reference, or 0 if no channel id was provided.- Returns:
- The channel id, or 0.
-
getGuildId
Returns the guild id for this reference, or 0 if no guild id was provided.- Returns:
- The guild id, or 0.
-
getJDA
Returns the JDA instance related to this message reference.- Returns:
- The corresponding JDA instance
-