Represents a message in a channel.

Constructors

  • Constructs a new Message object.

    Parameters

    • client: Client

      The client instance managing this message.

    • data: any

      The raw data representing the message.

    Returns Message

Properties

activity: any
application: any
applicationID: string
attachments: Attachment[]
author: User
call: any
channel: GuildChannel
channelID: string
components: any[]
content: string
editedTimestamp: string
embeds: Embed[]
flags: number
id: string
interaction: Interaction
interactionMetadata: any
mentionChannels: GuildChannel[]
mentionEveryone: boolean
mentionRoles: Role[]
mentions: User[]
messageReference: any
nonce: string | number
pinned: boolean
poll: any
position: number
reactions: Reaction[]
referencedMessage: Message
resolved: any
roleSubscriptionData: any
stickerItems: any[]
stickers: Sticker[]
thread: GuildChannel
timestamp: string
tts: boolean
type: number
webhookID: string

Methods

  • Adds a reaction to the specified message using the provided emoji.

    This method sends a request to the Discord API to add a reaction to a message in a specific channel. The reaction is represented by the emoji provided as a string (Unicode emoji or custom emoji ID).

    Parameters

    • emoji: string

      The emoji to react with. This can be a Unicode emoji or a custom emoji in the format name:id.

    Returns Promise<void>

    A promise that resolves when the reaction has been added.

    If there is an issue with the provided emoji or the API request fails.

  • Deletes a message from the specified channel.

    This method sends a request to the Discord API to permanently delete a specific message identified by its ID within the given channel. Once deleted, the message cannot be recovered.

    Returns Promise<void>

    A promise that resolves when the message has been successfully deleted.

    Throws an error if the deletion request fails. This may occur due to insufficient permissions, if the message does not exist, or if the channel is not accessible.

  • Edits the properties of the message with the specified options.

    This method sends a request to the Discord API to update the message's attributes identified by its ID within the specified channel. The updated message data will be reflected in the current instance after the operation is successful.

    Parameters

    • options: {
          allowed_mentions?: any;
          attachments?: any[];
          components?: any[];
          content?: string;
          embeds?: any[];
          flags?: number;
      }

      The options for editing the message, which can include: - content: The new content of the message (up to 2000 characters). - embeds: An array of embed objects (up to 10 rich embeds). - flags: Integer to edit the flags of a message (currently only SUPPRESS_EMBEDS). - allowed_mentions: An object specifying allowed mentions. - components: An array of message components (buttons, select menus, etc.). - attachments: An array of attachment objects for new files.

      • Optionalallowed_mentions?: any
      • Optionalattachments?: any[]
      • Optionalcomponents?: any[]
      • Optionalcontent?: string
      • Optionalembeds?: any[]
      • Optionalflags?: number

    Returns Promise<Message>

    A promise that resolves to the updated Message instance.

    If there is an issue with the provided options or the API request fails, such as insufficient permissions or invalid data.

  • Retrieves the reactions for a specific message using the provided emoji.

    This method sends a request to the Discord API to get a list of reactions for a specific message with the provided emoji. The emoji can be a Unicode emoji or a custom emoji ID.

    Parameters

    • emoji: string

      The emoji to search for. This can be a Unicode emoji or a custom emoji in the format name:id.

    • options: {
          after?: string;
          limit?: number;
          type?: number;
      } = {}

      Optional query parameters to refine the results.

      • Optionalafter?: string

        Get reactions after this user ID (optional).

      • Optionallimit?: number

        Max number of reactions to return (1-100).

      • Optionaltype?: number

        The type of reaction (optional).

    Returns Promise<Reaction[]>

    A promise that resolves to an array of Reaction instances for the given emoji.

    If there is an issue with the provided emoji or the API request fails.

  • Removes all reactions from the specified message.

    This method sends a request to the Discord API to remove all reactions from a message in a specific channel. It removes reactions for all emojis that were added to the message.

    Returns Promise<void>

    A promise that resolves when all reactions have been removed.

    If there is an issue with the API request or required properties are missing.

  • Removes the user's reaction from the specified message.

    This method sends a request to the Discord API to remove a reaction that the user added to a message. If a user ID is provided, it removes that specific user's reaction; otherwise, it removes the current user's reaction.

    Parameters

    • emoji: string

      The emoji for the reaction to be removed. This can be a Unicode emoji or a custom emoji in the format name:id.

    • OptionaluserId: string

      Optional. The ID of the user whose reaction should be removed. If not provided, it removes the current user's reaction.

    Returns Promise<void>

    A promise that resolves when the reaction has been removed.

    If there is an issue with the API request or required properties are missing.