SlackMessage
to
Sets the channel, private group, or IM channel to send the message to.
Name | Type | Required | Default | Description |
---|---|---|---|---|
channel |
| true | The channel, private group, or IM channel to send the message to. |
Return: The SlackMessage
instance.
text
Sets the text of the message.
Name | Type | Required | Default | Description |
---|---|---|---|---|
text |
| true | The text of the message. |
Return: The SlackMessage
instance.
actionsBlock
Creates and adds an Actions Block to the message's blocks
. After creating the block, it will call the provided callback
function to configure the Actions Block.
Name | Type | Required | Default | Description |
---|---|---|---|---|
callback |
| true | The callback function to configure the created Actions Block. |
Return: The SlackMessage
instance.
contextBlock
Creates and adds a Context Block to the message's blocks
. After creating the block, it will call the provided callback
function to configure the Context Block.
Name | Type | Required | Default | Description |
---|---|---|---|---|
callback |
| true | The callback function to configure the created Context Block. |
Return: The SlackMessage
instance.
dividerBlock
Creates and adds a Divider Block to the message's blocks
.
Name | Type | Required | Default | Description |
---|---|---|---|---|
No arguments |
Return: The SlackMessage
instance.
headerBlock
Creates and adds a Header Block to the message's blocks
with the passed-in text
. If a callback
function is provided, it is called to configure the Header Block.
Name | Type | Required | Default | Description |
---|---|---|---|---|
text |
| true | The text for the header. | |
callback |
| false |
| The callback function to configure the created Header Block. |
Return: The SlackMessage
instance.
imageBlock
Creates and adds an Image Block to the message's blocks
with the passed-in imageUrl
.
If altText
is not provided when constructing the Image Block, it must be provided in the callback
.
If a callback
function is provided, it is called to configure the Image Block.
Name | Type | Required | Default | Description |
---|---|---|---|---|
imageUrl |
| true | The url for the image of the block. | |
altText |
| false |
| The alt text for the image. If no alt text is provided, it must be configured in the |
callback |
| false |
| The callback function to configure the created Image Block. |
Return: The SlackMessage
instance.
sectionBlock
Creates and adds a Section Block to the message's blocks
.
The provided callback
function is called to configure the Section Block.
Name | Type | Required | Default | Description |
---|---|---|---|---|
callback |
| true | The callback function to configure the created Section Block. |
Return: The SlackMessage
instance.
emoji
Sets the icon of the Slack Message to be the provided emoji.
Name | Type | Required | Default | Description |
---|---|---|---|---|
icon |
| true | The emoji code to set as the icon, e.g. |
Return: The SlackMessage
instance.
image
Sets the icon of the Slack Message to be the provided image URL.
Name | Type | Required | Default | Description |
---|---|---|---|---|
image |
| true | The image URL to set as the icon. |
Return: The SlackMessage
instance.
metadata
Add metadata for the given event type.
Name | Type | Required | Default | Description |
---|---|---|---|---|
eventType |
| true | The event type to track metadata for. | |
payload |
| false |
| The metadata to track. |
Return: The SlackMessage
instance.
disableMarkdownParsing
Disables markdown parsing of the Slack Message text.
Name | Type | Required | Default | Description |
---|---|---|---|---|
No arguments |
Return: The SlackMessage
instance.
unfurlLinks
Pass true
to enable unfurling of primarily text-based content.
Name | Type | Required | Default | Description |
---|---|---|---|---|
unfurlLinks |
| false |
| Boolean flag to unfurl links or not. |
Return: The SlackMessage
instance.
unfurlMedia
Pass true
to enable unfurling of media content.
Name | Type | Required | Default | Description |
---|---|---|---|---|
unfurlMedia |
| false |
| Boolean flag to unfurl media or not. |
Return: The SlackMessage
instance.
username
Sets the username for the Slack Bot.
Name | Type | Required | Default | Description |
---|---|---|---|---|
username |
| true | The username to use for the Slack Bot. |
Return: The SlackMessage
instance.
getMemento
Returns a serializable representation of this Slack Message.
Name | Type | Required | Default | Description |
---|---|---|---|---|
No arguments |
Return: (struct
) The serializable Slack Message
Throws: Megaphone.Provider.SlackBlockException
dump
Sends either the memento or a link to the Slack's BlockKit Builder to writeDump
.
Name | Type | Required | Default | Description |
---|---|---|---|---|
raw |
| false |
| If true, outputs the memento of the message. Otherwise, outputs a URL to Slack's BlockKit Builder. |
This method also accepts all the same arguments as writeDump
.
Return: (void
)
when
Control-flow helper to have if
/ else
statements with method chaining.
Name | Type | Required | Default | Description |
---|---|---|---|---|
target |
| true | The boolean evaluator. | |
success |
| true | The callback to execute if the boolean value is | |
failure |
| false |
| The optional callback to execute if the boolean value is |
Return: The SlackMessage
instance.
Last updated