Hash :
49013485
Author :
Thomas de Grivel
Date :
2022-02-03T12:17:34
defmodule Discord do
def error(params) do
url = Application.get_env(:kmxgit, :discord_errors_webhook)
reason = if (try do params.reason.message rescue _ -> nil end) do
type = params.reason.__struct__
"#{type}: #{params.reason.message}"
else
inspect(params.reason)
end
stack = Stack.to_string(params.stack)
message = %{content: "```#{params.kind} #{reason}\n\n#{stack}```"}
json = Jason.encode!(message)
HTTPoison.post(url, json, [{"Content-Type", "application/json"}])
end
end