diff --git a/lib/rest.ex b/lib/rest.ex index a418108..a5d412b 100644 --- a/lib/rest.ex +++ b/lib/rest.ex @@ -106,6 +106,9 @@ defmodule Crux.Rest do def create_message(%Message{channel_id: channel_id}, args), do: create_message(channel_id, args) def create_message(%Channel{id: channel_id}, args), do: create_message(channel_id, args) + def create_message(channel_id, not_map) when not is_map(not_map), + do: create_message(channel_id, Map.new(not_map)) + def create_message(channel_id, %{files: files} = args) when is_number(channel_id) do Enum.reduce_while(files, [], fn file, acc -> with {:error, error} <- Util.map_file(file) do @@ -133,7 +136,7 @@ defmodule Crux.Rest do end end - def create_message(channel_id, args), do: real_create_message(channel_id, Map.new(args)) + def create_message(channel_id, args), do: real_create_message(channel_id, args) defp real_create_message(channel_id, args, disposition \\ []) do Rest.Base.queue(:post, Endpoints.channel_messages(channel_id), args, disposition)