diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9f5e90d..ff6a826 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,7 +3,7 @@ on: [pull_request, push] jobs: mix_test: name: mix test (Elixir ${{ matrix.elixir }} OTP ${{ matrix.otp }}) - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 strategy: fail-fast: false matrix: @@ -14,7 +14,7 @@ jobs: otp: 23.0.3 steps: - uses: actions/checkout@v2.3.2 - - uses: actions/setup-elixir@v1.5.0 + - uses: erlef/setup-elixir@v1 with: otp-version: ${{ matrix.otp }} elixir-version: ${{ matrix.elixir }} diff --git a/lib/Discord/Gateway/manager.ex b/lib/Discord/Gateway/manager.ex index 0286f43..a07b8db 100644 --- a/lib/Discord/Gateway/manager.ex +++ b/lib/Discord/Gateway/manager.ex @@ -37,7 +37,14 @@ defmodule Alchemy.Discord.Gateway.Manager do Api.get!(url, token).body |> (fn x -> Poison.Parser.parse!(x, %{}) end).() - {json["url"] <> "?v=6&encoding=json", json["shards"]} + case json do + %{"retry_after" => ms} -> + :timer.sleep(ms) + get_url(token, []) + + _ -> + {json["url"] <> "?v=6&encoding=json", json["shards"]} + end end defp now, do: DateTime.utc_now() |> DateTime.to_unix() diff --git a/mix.exs b/mix.exs index 78411c0..7d31234 100644 --- a/mix.exs +++ b/mix.exs @@ -22,7 +22,7 @@ defmodule Alchemy.Mixfile do defp deps do [ - {:httpoison, "~> 1.5"}, + {:httpoison, "~> 1.8"}, {:earmark, "~> 1.3", only: :dev}, {:websocket_client, "~> 1.3"}, {:ex_doc, "~> 0.20", only: :dev},