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
- .resolveFiles(file) ⇒
Promise.<(Buffer|null)>
- .resolveData([payload]) ⇒
Object
- .resolveMessageFlags(flags) ⇒
number
|undefined
- .resolveModal(data, type) ⇒
Object
- .resolveWebhook(payload, extras) ⇒
object
- .resolveDefers(data, [type]) ⇒
object
- .create(payload, type) ⇒
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.
Param | Type | Description |
---|---|---|
payload | Object | The payload object. |
type | string | The 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.
Param | Type | Description |
---|---|---|
file | Buffer | MessageAttachment | string | The 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.
Param | Type | Description |
---|---|---|
[payload] | Object | The 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.
Param | Type | Description |
---|---|---|
flags | number | The 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.
Param | Type | Description |
---|---|---|
data | Object | The modal data object. |
type | string | The 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.
Param | Type | Description |
---|---|---|
payload | object | The webhook payload object. |
extras | object | Additional 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.
Param | Type | Default | Description |
---|---|---|---|
data | object | The data object to resolve. | |
[type] | number | 5 | The type of the resolved data. |