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