Class MessageReference


  • public class MessageReference
    extends java.lang.Object
    An object representing a reference in a Discord message.
    See Also:
    Message.getMessageReference()
    • Constructor Summary

      Constructors 
      Constructor Description
      MessageReference​(long messageId, long channelId, long guildId, Message referencedMessage, JDA api)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      MessageChannel getChannel()
      The channel from which this message originates.
      java.lang.String getChannelId()
      Returns the channel id for this reference, or 0 if no channel id was provided.
      long getChannelIdLong()
      Returns the channel id for this reference, or 0 if no channel id was provided.
      Guild getGuild()
      The guild for this reference.
      java.lang.String getGuildId()
      Returns the guild id for this reference, or 0 if no guild id was provided.
      long getGuildIdLong()
      Returns the guild id for this reference, or 0 if no guild id was provided.
      JDA getJDA()
      Returns the JDA instance related to this message reference.
      Message getMessage()
      The resolved message, if available.
      java.lang.String getMessageId()
      Returns the message id for this reference, or 0 if no message id was provided.
      long getMessageIdLong()
      Returns the message id for this reference, or 0 if no message id was provided.
      RestAction<Message> resolve()
      Retrieves the referenced message for this message.
      RestAction<Message> resolve​(boolean update)
      Retrieves the referenced message for this message.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • MessageReference

        public MessageReference​(long messageId,
                                long channelId,
                                long guildId,
                                @Nullable
                                Message referencedMessage,
                                JDA api)
    • Method Detail

      • getMessage

        @Nullable
        public Message getMessage()
        The resolved message, if available.

        This will have different meaning depending on the type of message. Usually, this is a INLINE_REPLY reference. This can be null even if the type is INLINE_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:
        resolve()
      • getChannel

        @Nullable
        public MessageChannel 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:
        getChannelId()
      • getGuild

        @Nullable
        public Guild 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:
        getGuildId()
      • 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

        @Nonnull
        public java.lang.String getMessageId()
        Returns the message id for this reference, or 0 if no message id was provided.
        Returns:
        The message id, or 0.
      • getChannelId

        @Nonnull
        public java.lang.String getChannelId()
        Returns the channel id for this reference, or 0 if no channel id was provided.
        Returns:
        The channel id, or 0.
      • getGuildId

        @Nonnull
        public java.lang.String getGuildId()
        Returns the guild id for this reference, or 0 if no guild id was provided.
        Returns:
        The guild id, or 0.
      • getJDA

        @Nonnull
        public JDA getJDA()
        Returns the JDA instance related to this message reference.
        Returns:
        The corresponding JDA instance