slash v2.0.4 Slash.Command View Source
Slash.Command
stores all command data received from Slack when invoking a command.
The primary user facing functionality provided by this module is async/2
.
Link to this section Summary
Functions
Starts an async task under the Slash.Supervisor
so the command can automatically be
responded to upon completion
Takes keys from the Slack payload and builds the Command
struct
Puts a value into the %Command{}
under the key, key
Responds to the %Command{}
with message
Returns true
or false
depending on if this command is populated with all required fields
Link to this section Types
t()
View Source
t() :: %Slash.Command{
args: [String.t()],
channel_id: String.t(),
channel_name: String.t(),
command: String.t(),
data: map(),
enterprise_id: String.t(),
enterprise_name: String.t(),
response_url: String.t(),
team_domain: String.t(),
team_id: String.t(),
text: String.t(),
trigger_id: String.t(),
user_id: String.t(),
user_name: String.t()
}
t() :: %Slash.Command{ args: [String.t()], channel_id: String.t(), channel_name: String.t(), command: String.t(), data: map(), enterprise_id: String.t(), enterprise_name: String.t(), response_url: String.t(), team_domain: String.t(), team_id: String.t(), text: String.t(), trigger_id: String.t(), user_id: String.t(), user_name: String.t() }
Link to this section Functions
async(command, func, opts \\ [])
View Source
async(t(), (() -> Slash.Builder.command_response()), keyword()) :: :async
async(t(), (() -> Slash.Builder.command_response()), keyword()) :: :async
Starts an async task under the Slash.Supervisor
so the command can automatically be
responded to upon completion.
If you intend to use async commands, you MUST have Slash.Supervisor
started.
Options
The following are valid options when calling async/3
.
- :timeout - specific the
Task.async/2
timeout option to be used.
Examples
command :async_reply, fn command ->
async command, fn ->
Process.sleep(5_000)
"Hello!"
end
end
from_params(body) View Source
Takes keys from the Slack payload and builds the Command
struct.
put_data(command, key, value) View Source
Puts a value into the %Command{}
under the key, key
.
send_response(command, message) View Source
Responds to the %Command{}
with message
.
Note, this is for internal usage with async commands. Please see Slash.Builder
for
valid return types from command functions.
valid?(command) View Source
Returns true
or false
depending on if this command is populated with all required fields.
A command struct is considered invalid if any field is nil at this point.