Skip to content

MessagePayload

MessagePayload

Represents a message payload and provides methods for creating and resolving message data.

Kind: global class

MessagePayload.create(payload, type) ⇒ Promise.<Object> | Object

Creates a payload for a given type.

Kind: static method of MessagePayload
Returns: Promise.<Object> | Object - - The created payload.

ParamTypeDescription
payloadObjectThe payload object.
typestringThe type of payload to create.

MessagePayload.resolveFiles(file) ⇒ Promise.<(Buffer|null)>

Resolves a file to a Buffer object.

Kind: static method of MessagePayload
Returns: Promise.<(Buffer|null)> - - A Promise that resolves to a Buffer object or null if the file cannot be resolved.

ParamTypeDescription
fileBuffer | MessageAttachment | stringThe file to resolve.

MessagePayload.resolveData([payload]) ⇒ Object

Resolves the data payload for a message.

Kind: static method of MessagePayload
Returns: Object - - The resolved data payload for the message.

ParamTypeDescription
[payload]ObjectThe payload object containing the message data.

MessagePayload.resolveMessageFlags(flags) ⇒ number | undefined

Resolves the message flags and returns the parsed bitfield value.

Kind: static method of MessagePayload
Returns: number | undefined - The parsed bitfield value of the message flags.

ParamTypeDescription
flagsnumberThe message flags to resolve.

MessagePayload.resolveModal(data, type) ⇒ Object

Resolves the modal data and returns an object with the specified type and data.

Kind: static method of MessagePayload
Returns: Object - - An object with the specified type and data.

ParamTypeDescription
dataObjectThe modal data object.
typestringThe type of the modal.

MessagePayload.resolveWebhook(payload, extras) ⇒ object

Resolves a webhook payload by merging it with additional extras.

Kind: static method of MessagePayload
Returns: object - - The resolved webhook payload with merged extras.

ParamTypeDescription
payloadobjectThe webhook payload object.
extrasobjectAdditional extras to merge with the payload.

MessagePayload.resolveDefers(data, [type]) ⇒ object

Resolves deferred data by assigning the appropriate flags and returning the resolved data.

Kind: static method of MessagePayload
Returns: object - - The resolved data object with assigned flags.

ParamTypeDefaultDescription
dataobjectThe data object to resolve.
[type]number5The type of the resolved data.