Class Message<T>

Represents a message.

Type Parameters

Hierarchy

Constructors

Properties

_cachedChannel: any
_cachedGuild?: any
activity?: MessageActivity

The activity associated with this message.

The application associated with this message. This can be present in two scenarios:

applicationID: null | string

The ID of the application associated with this message. This can be present in two scenarios:

attachments: TypedCollection<string, RawAttachment, Attachment, []>

The attachments on this message.

author: User

The author of this message.

channelID: string

The ID of the channel this message was created in.

components: MessageActionRow[]

The components on this message.

content: string

The content of this message.

editedTimestamp: null | Date

The timestamp at which this message was last edited.

embeds: Embed[]

The embeds on this message.

flags: number

The flags on this message.

guildID: T extends AnyTextableGuildChannel
    ? string
    : null | string

The ID of the guild this message is in.

id: string
interaction?: MessageInteraction

The interaction info, if this message was the result of an interaction.

member: T extends AnyTextableGuildChannel
    ? Member
    : undefined | Member

The member that created this message, if this message is in a guild.

mentionChannels?: ChannelMention[]

Channels mentioned in a CROSSPOSTED channel follower message. See Discord's docs for more information.

mentions: {
    channels: string[];
    everyone: boolean;
    members: Member[];
    roles: string[];
    users: User[];
}

The mentions in this message.

Type declaration

  • channels: string[]

    The ids of the channels mentioned in this message.

  • everyone: boolean

    If @everyone/@here is mentioned in this message.

  • members: Member[]

    The members mentioned in this message.

  • roles: string[]

    The ids of the roles mentioned in this message.

  • users: User[]

    The users mentioned in this message.

messageReference?: MessageReference

If this message is a REPLY or THREAD_STARTER_MESSAGE, some info about the referenced message.

nonce?: string | number

A nonce for ensuring a message was sent.

pinned: boolean

If this message is pinned.

position?: number

This message's relative position, if in a thread.

reactions: Record<string, MessageReaction>

The reactions on this message.

referencedMessage?: null | Message<Uncached | AnyTextableChannel>

If this message is a REPLY or THREAD_STARTER_MESSAGE, this will be the message that's referenced.

stickerItems?: StickerItem[]

The sticker items on this message.

The thread associated with this message, if any.

timestamp: Date

The timestamp at which this message was sent.

tts: boolean

If this message was read aloud.

The type of this message.

webhookID?: string

The webhook associated with this message, if sent via a webhook. This only has an id property.

Accessors

  • get channel(): T extends AnyTextableChannel
        ? T
        : undefined
  • The channel this message was created in.

    Returns T extends AnyTextableChannel
        ? T
        : undefined

  • get createdAt(): Date
  • Returns Date

  • get guild(): T extends AnyTextableGuildChannel
        ? Guild
        : null | Guild
  • The guild this message is in. This will throw an error if the guild is not cached.

    Returns T extends AnyTextableGuildChannel
        ? Guild
        : null | Guild

  • A link to this message.

    Returns string

Methods

  • Add a reaction to this message.

    Parameters

    • emoji: string

      The reaction to add to the message. name:id for custom emojis, and the unicode codepoint for default emojis.

    Returns Promise<void>

  • Crosspost this message in an announcement channel.

    Returns Promise<Message<T>>

  • Delete this message.

    Parameters

    • Optional reason: string

      The reason for deleting the message.

    Returns Promise<void>

  • Remove a reaction from this message.

    Parameters

    • emoji: string

      The reaction to remove from the message. name:id for custom emojis, and the unicode codepoint for default emojis.

    • Optional user: string

      The user to remove the reaction from, @me for the current user (default).

    Returns Promise<void>

  • Remove all, or a specific emoji's reactions from this message.

    Parameters

    • Optional emoji: string

      The reaction to remove from the message. name:id for custom emojis, and the unicode codepoint for default emojis. Omit to remove all reactions.

    Returns Promise<void>

  • Delete this message as a webhook.

    Parameters

    Returns Promise<void>

  • Edit this message.

    Parameters

    Returns Promise<Message<T>>

  • Edit this message as a webhook.

    Parameters

    Returns Promise<Message<T>>

  • Get the users who reacted with a specific emoji on this message.

    Parameters

    • emoji: string

      The reaction to remove from the message. name:id for custom emojis, and the unicode codepoint for default emojis.

    • Optional options: GetReactionsOptions

      The options for getting the reactions.

    Returns Promise<User[]>

  • Whether this message belongs to a cached guild channel. The only difference on using this method over a simple if statement is to easily update all the message properties typing definitions based on the channel it belongs to.

    Returns this is Message<AnyTextableGuildChannel>

  • Whether this message belongs to a direct message channel (PrivateChannel or uncached). The only difference on using this method over a simple if statement is to easily update all the message properties typing definitions based on the channel it belongs to.

    Returns this is Message<PrivateChannel | Uncached>

  • Pin this message.

    Parameters

    • Optional reason: string

      The reason for pinning the message.

    Returns Promise<void>

  • Returns JSONMessage

  • Returns string

  • Unpin this message.

    Parameters

    • Optional reason: string

      The reason for unpinning the message.

    Returns Promise<void>

  • Parameters

    Returns void

  • Parameters

    • Optional timestamp: number | Date

    Returns string

  • Parameters

    • id: string

    Returns Date

  • Parameters

    • id: string

    Returns number

Generated using TypeDoc