Represents the payload for creating or updating a message. This class encapsulates all the parameters needed to send a message in Discord.

Constructors

  • Creates a new MessagePayload instance.

    Parameters

    • Optionaldata: {
          allowed_mentions?: {
              everyone?: boolean;
              repliedUser?: boolean;
              roles?: boolean | string[];
              users?: boolean | string[];
          };
          attachments?: {
              description?: string;
              filename: string;
              id: number;
          }[];
          components?: any[];
          content?: string;
          embeds?: any[];
          enforce_nonce?: boolean;
          flags?: number;
          message_reference?: {
              channelID?: string;
              failIfNotExists?: boolean;
              guildID?: string;
              messageID: string;
          };
          nonce?: string | number;
          poll?: any;
          sticker_ids?: string[];
          tts?: boolean;
      }

      Optional initial data to set in the payload.

      • Optionalallowed_mentions?: {
            everyone?: boolean;
            repliedUser?: boolean;
            roles?: boolean | string[];
            users?: boolean | string[];
        }
        • Optionaleveryone?: boolean
        • OptionalrepliedUser?: boolean
        • Optionalroles?: boolean | string[]
        • Optionalusers?: boolean | string[]
      • Optionalattachments?: {
            description?: string;
            filename: string;
            id: number;
        }[]
      • Optionalcomponents?: any[]
      • Optionalcontent?: string
      • Optionalembeds?: any[]
      • Optionalenforce_nonce?: boolean
      • Optionalflags?: number
      • Optionalmessage_reference?: {
            channelID?: string;
            failIfNotExists?: boolean;
            guildID?: string;
            messageID: string;
        }
        • OptionalchannelID?: string
        • OptionalfailIfNotExists?: boolean
        • OptionalguildID?: string
        • messageID: string
      • Optionalnonce?: string | number
      • Optionalpoll?: any
      • Optionalsticker_ids?: string[]
      • Optionaltts?: boolean

    Returns MessagePayload

Accessors

  • get allowedMentions(): {
        everyone?: boolean;
        repliedUser?: boolean;
        roles?: boolean | string[];
        users?: boolean | string[];
    }
  • Gets the allowed mentions for the message.

    Returns {
        everyone?: boolean;
        repliedUser?: boolean;
        roles?: boolean | string[];
        users?: boolean | string[];
    }

    The allowed mentions object.

    • Optionaleveryone?: boolean
    • OptionalrepliedUser?: boolean
    • Optionalroles?: boolean | string[]
    • Optionalusers?: boolean | string[]
  • set allowedMentions(value): void
  • Sets the allowed mentions for the message.

    Parameters

    • value: {
          everyone?: boolean;
          repliedUser?: boolean;
          roles?: boolean | string[];
          users?: boolean | string[];
      }

      The allowed mentions object.

      • Optionaleveryone?: boolean
      • OptionalrepliedUser?: boolean
      • Optionalroles?: boolean | string[]
      • Optionalusers?: boolean | string[]

    Returns void

  • get attachments(): {
        description?: string;
        filename: string;
        id: number;
    }[]
  • Gets the attachments for the message.

    Returns {
        description?: string;
        filename: string;
        id: number;
    }[]

    An array of attachment objects.

  • set attachments(value): void
  • Sets the attachments for the message.

    Parameters

    • value: {
          description?: string;
          filename: string;
          id: number;
      }[]

      An array of attachment objects.

    Returns void

  • get components(): any[]
  • Gets the components for the message.

    Returns any[]

    An array of message component objects.

  • set components(value): void
  • Sets the components for the message.

    Parameters

    • value: any[]

      An array of message component objects.

    Returns void

  • get content(): string
  • Gets the content of the message.

    Returns string

    The message content.

  • set content(value): void
  • Sets the content of the message.

    Parameters

    • value: string

      The message content. Should be up to 2000 characters.

    Returns void

    Error if the content exceeds 2000 characters.

  • get embeds(): any[]
  • Gets the embeds for the message.

    Returns any[]

    An array of embed objects.

  • set embeds(value): void
  • Sets the embeds for the message.

    Parameters

    • value: any[]

      An array of embed objects. Up to 10 embeds allowed.

    Returns void

    Error if the array exceeds 10 embeds.

  • get enforceNonce(): boolean
  • Gets the enforce nonce flag.

    Returns boolean

    True if nonce uniqueness should be enforced.

  • set enforceNonce(value): void
  • Sets the enforce nonce flag.

    Parameters

    • value: boolean

      True if nonce uniqueness should be enforced.

    Returns void

  • get messageReference(): {
        channelID?: string;
        failIfNotExists?: boolean;
        guildID?: string;
        messageID: string;
    }
  • Gets the message reference object.

    Returns {
        channelID?: string;
        failIfNotExists?: boolean;
        guildID?: string;
        messageID: string;
    }

    The message reference object.

    • OptionalchannelID?: string
    • OptionalfailIfNotExists?: boolean
    • OptionalguildID?: string
    • messageID: string
  • set messageReference(value): void
  • Sets the message reference object for replies or forwards.

    Parameters

    • value: {
          channelID?: string;
          failIfNotExists?: boolean;
          guildID?: string;
          messageID: string;
      }

      The message reference object. Must include messageID.

      • OptionalchannelID?: string
      • OptionalfailIfNotExists?: boolean
      • OptionalguildID?: string
      • messageID: string

    Returns void

    Error if messageID is not provided.

  • get nonce(): string | number
  • Gets the nonce for the message.

    Returns string | number

    The nonce value.

  • set nonce(value): void
  • Sets the nonce for the message.

    Parameters

    • value: string | number

      The nonce value. Should be up to 25 characters if string.

    Returns void

    Error if the nonce exceeds 25 characters.

  • get stickerIDs(): string[]
  • Gets the sticker IDs for the message.

    Returns string[]

    An array of sticker IDs.

  • set stickerIDs(value): void
  • Sets the sticker IDs for the message.

    Parameters

    • value: string[]

      An array of sticker IDs. Up to 3 stickers allowed.

    Returns void

    Error if the array exceeds 3 stickers.

  • get tts(): boolean
  • Gets the TTS flag for the message.

    Returns boolean

    True if the message is a TTS message.

  • set tts(value): void
  • Sets the TTS flag for the message.

    Parameters

    • value: boolean

      True if the message should be sent as TTS.

    Returns void

Methods

  • Returns Promise<{
        allowed_mentions?: any;
        attachments?: any[];
        components?: any[];
        content?: string;
        embeds?: any[];
        enforce_nonce?: boolean;
        files: any[];
        flags?: number;
        message_reference?: any;
        nonce?: string | number;
        poll?: any;
        sticker_ids?: string[];
        tts?: boolean;
    }>

  • Converts the payload to a JSON-serializable object.

    Returns any

    A JSON-serializable representation of the payload.