Class MessageReference

    • 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 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 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 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