Class MessageImpl

java.lang.Object
com.mewna.catnip.entity.impl.message.MessageImpl
All Implemented Interfaces:
Entity, Message, HasChannel, Snowflake, Timestamped, RequiresCatnip

public class MessageImpl extends Object implements Message, RequiresCatnip, Timestamped
Since:
9/2/18.
Author:
amy
  • Constructor Details

  • Method Details

    • catnip

      public void catnip(@Nonnull Catnip catnip)
      Specified by:
      catnip in interface RequiresCatnip
    • timestamp

      @Nonnull public OffsetDateTime timestamp()
      Description copied from interface: Message
      When the message was sent.
      Specified by:
      timestamp in interface Message
      Returns:
      Date and time the message was sent.
    • editedTimestamp

      @Nullable public OffsetDateTime editedTimestamp()
      Description copied from interface: Message
      When the message was last edited, if ever.
      Previous edits are not exposed, only the most recent.
      Specified by:
      editedTimestamp in interface Message
      Returns:
      The date and time the message was last edited. Null if the message was never edited.
    • attachments

      @Nonnull public List<Message.Attachment> attachments()
      Description copied from interface: Message
      List of files sent with the message.
      Specified by:
      attachments in interface Message
      Returns:
      List of files sent with the message. Never null.
    • reactions

      @Nonnull public List<Message.Reaction> reactions()
      Description copied from interface: Message
      List of reactions added to the message.
      This list will not be updated.
      Specified by:
      reactions in interface Message
      Returns:
      List of reactions added to the message. Never null.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • builder

      public static MessageImpl.MessageImplBuilder builder()
    • catnip

      public Catnip catnip()
      Description copied from interface: Entity
      Returns the catnip instance associated with this entity.
      Specified by:
      catnip in interface Entity
      Returns:
      The catnip instance of this entity.
    • idAsLong

      public long idAsLong()
      Description copied from interface: Snowflake
      The ID of this snowflake, as a long.
      Specified by:
      idAsLong in interface Snowflake
      Returns:
      Long representing the ID.
    • channelIdAsLong

      public long channelIdAsLong()
      Specified by:
      channelIdAsLong in interface HasChannel
    • author

      public User author()
      Description copied from interface: Message
      Guild-agnostic representation of the author of the message.
      Specified by:
      author in interface Message
      Returns:
      The author of the message. Never null.
      See Also:
    • content

      public String content()
      Description copied from interface: Message
      The message's content. Is just an empty string for embed-only messages.
      Specified by:
      content in interface Message
      Returns:
      String containing the message body. Never null.
    • tts

      public boolean tts()
      Description copied from interface: Message
      Whether or not the message was sent using the /TTS command, making clients read
      the message aloud using their text-to-speech engine.
      Specified by:
      tts in interface Message
      Returns:
      True if the message is to be spoken, false otherwise.
    • mentionsEveryone

      public boolean mentionsEveryone()
      Description copied from interface: Message
      Whether the message mentions everyone.
      Specified by:
      mentionsEveryone in interface Message
      Returns:
      True if the message mentions everyone, false otherwise.
    • mentionedUsers

      public List<User> mentionedUsers()
      Description copied from interface: Message
      List of users @mentioned by this message.
      Specified by:
      mentionedUsers in interface Message
      Returns:
      List of Users. Never null.
    • mentionedMembers

      public List<Member> mentionedMembers()
      Description copied from interface: Message
      A list of members mentioned by this message. Will contain the same users as Message.mentionedUsers(). Will always be empty for DMs.
      Specified by:
      mentionedMembers in interface Message
      Returns:
      List of members. Never null.
    • mentionedRoleIds

      public List<String> mentionedRoleIds()
      Description copied from interface: Message
      List of the ids of all roles @mentioned by this message.
      All users with at least one of these roles will also be mentioned.
      Specified by:
      mentionedRoleIds in interface Message
      Returns:
      List of role ids. Never null.
    • embeds

      public List<Embed> embeds()
      Description copied from interface: Message
      List of embeds in the message.
      Specified by:
      embeds in interface Message
      Returns:
      List of embeds. Never null.
    • activity

      public Message.MessageActivity activity()
      Specified by:
      activity in interface Message
      Returns:
      The message's activity. Sent in Rich Presence-related embeds. May be null.
    • application

      public Message.MessageApplication application()
      Specified by:
      application in interface Message
      Returns:
      The message's application. Sent in Rich Presence-related embeds. May be null.
    • messageReference

      public MessageReference messageReference()
      Specified by:
      messageReference in interface Message
      Returns:
      Reference data sent with crossposted messages.
    • nonce

      public String nonce()
      Description copied from interface: Message
      The message's nonce snowflake.
      Nonces are used to validating messages have been sent, as two identical messages
      with the same nonce are considered to be re-sent due to network errors.
      Specified by:
      nonce in interface Message
      Returns:
      unique String nonce for the message. Can be null.
    • pinned

      public boolean pinned()
      Description copied from interface: Message
      Whether the message is pinned.
      This will always be false on new messages.
      Specified by:
      pinned in interface Message
      Returns:
      True if the message is pinned, false otherwise.
    • webhookIdAsLong

      public long webhookIdAsLong()
      Description copied from interface: Message
      The snowflake ID of the webhook this message was sent by.
      Specified by:
      webhookIdAsLong in interface Message
      Returns:
      Long representing the webhook ID. 0 if not sent by a webhook.
    • type

      public MessageType type()
      Description copied from interface: Message
      The type of message. Use this to tell normal messages from system messages.
      Specified by:
      type in interface Message
      Returns:
      enum representing the message type. Never null.
    • member

      public Member member()
      Description copied from interface: Message
      The author of the message, as a member of the guild.
      Can be null if the author is no longer in the guild, or if the message was sent
      by a fake user.
      Specified by:
      member in interface Message
      Returns:
      Member representation of the author. Can be null.
    • guildIdAsLong

      public long guildIdAsLong()
      Description copied from interface: Message
      The snowflake ID of the guild this message was sent in.
      Specified by:
      guildIdAsLong in interface Message
      Returns:
      Long representing the guild ID. Null if sent in DMs.
    • flagsRaw

      public int flagsRaw()
      Specified by:
      flagsRaw in interface Message
      Returns:
      Raw bits of flags set on this message.
    • mentionedChannels

      public List<ChannelMention> mentionedChannels()
      Specified by:
      mentionedChannels in interface Message
      Returns:
      All channels mentioned in this message. Not all messages will have this, nor will all channels mentioned in a message have a corresponding mention object.
    • referencedMessage

      public Message referencedMessage()
      Description copied from interface: Message
      The message that was referenced by this message. Used for inline replies. If null, the message was deleted. If present and not null, it is the message that this message is replying to. If not present and the type is MessageType.REPLY, the backend couldn't fetch the relevant message.
      Specified by:
      referencedMessage in interface Message
      Returns:
      A message reference.
    • stickers

      public List<Sticker> stickers()
      Specified by:
      stickers in interface Message
      Returns:
      The stickers sent with this message.
    • components

      public List<MessageComponent> components()
      Specified by:
      components in interface Message
      Returns:
      All components attached to this message. Top-level components must be ActionRows.
    • idAsLong

      public MessageImpl idAsLong(long idAsLong)
      Returns:
      this.
    • channelIdAsLong

      public MessageImpl channelIdAsLong(long channelIdAsLong)
      Returns:
      this.
    • author

      public MessageImpl author(User author)
      Returns:
      this.
    • content

      public MessageImpl content(String content)
      Returns:
      this.
    • timestamp

      public MessageImpl timestamp(String timestamp)
      Returns:
      this.
    • editedTimestamp

      public MessageImpl editedTimestamp(String editedTimestamp)
      Returns:
      this.
    • tts

      public MessageImpl tts(boolean tts)
      Returns:
      this.
    • mentionsEveryone

      public MessageImpl mentionsEveryone(boolean mentionsEveryone)
      Returns:
      this.
    • mentionedUsers

      public MessageImpl mentionedUsers(List<User> mentionedUsers)
      Returns:
      this.
    • mentionedMembers

      public MessageImpl mentionedMembers(List<Member> mentionedMembers)
      Returns:
      this.
    • mentionedRoleIds

      public MessageImpl mentionedRoleIds(List<String> mentionedRoleIds)
      Returns:
      this.
    • attachments

      public MessageImpl attachments(List<Message.Attachment> attachments)
      Returns:
      this.
    • embeds

      public MessageImpl embeds(List<Embed> embeds)
      Returns:
      this.
    • reactions

      public MessageImpl reactions(List<Message.Reaction> reactions)
      Returns:
      this.
    • activity

      public MessageImpl activity(Message.MessageActivity activity)
      Returns:
      this.
    • application

      public MessageImpl application(Message.MessageApplication application)
      Returns:
      this.
    • messageReference

      public MessageImpl messageReference(MessageReference messageReference)
      Returns:
      this.
    • nonce

      public MessageImpl nonce(String nonce)
      Returns:
      this.
    • pinned

      public MessageImpl pinned(boolean pinned)
      Returns:
      this.
    • webhookIdAsLong

      public MessageImpl webhookIdAsLong(long webhookIdAsLong)
      Returns:
      this.
    • type

      public MessageImpl type(MessageType type)
      Returns:
      this.
    • member

      public MessageImpl member(Member member)
      Returns:
      this.
    • guildIdAsLong

      public MessageImpl guildIdAsLong(long guildIdAsLong)
      Returns:
      this.
    • flagsRaw

      public MessageImpl flagsRaw(int flagsRaw)
      Returns:
      this.
    • mentionedChannels

      public MessageImpl mentionedChannels(List<ChannelMention> mentionedChannels)
      Returns:
      this.
    • referencedMessage

      public MessageImpl referencedMessage(Message referencedMessage)
      Returns:
      this.
    • stickers

      public MessageImpl stickers(List<Sticker> stickers)
      Returns:
      this.
    • components

      public MessageImpl components(List<MessageComponent> components)
      Returns:
      this.