Closed yujonglee closed 2 weeks ago
defp discord() do if Application.get_env(:nostrum, :token), do: [DiscordBot], else: [] end
Is DiscordBot
your consumer?
You will want to start Nostrum.Application
ahead of DiscordBot
,
because Nostrum.ConsumerGroup
(and the rest of nostrum, currently at
least) will be started under Nostrum's own supervisor. You probably
want:
defp discord() do if Application.get_env(:nostrum, :token), do: [Nostrum.Application, DiscordBot], else: [] end
Let me know if this helps!
@jchristgit
Yes, DiscordBot
is my consumer.
I tried this:
defp discord() do
if Application.get_env(:nostrum, :token) do
[Nostrum.Application, DiscordBot]
else
[]
end
end
Now error message changed to:
shutdown: failed to start child: Nostrum.Application
** (EXIT) shutdown: failed to start child: Nostrum.Shard.Supervisor
** (EXIT) exited in: :gen_statem.call(Nostrum.Api.Ratelimiter, {:queue, %{params: [], body: "", headers: [{"content-type", "application/json"}], method: :get, route: "/gateway/bot"}}, :infinity)
** (EXIT) exited in: :gen_server.call(:gun_conns_sup, {:start_child, [#PID<0.438.0>, ~c"discord.com", 443, %{retry: 0, connect_timeout: 5000, domain_lookup_timeout: 5000, tls_handshake_timeout: 5000, tls_opts: [verify: :verify_peer ...
** (EXIT) exited in: :gen_server.call(:gun_conns_sup, {:start_child,
That's probably going to be because gun
isn't started.
Maybe you can put :gun_app
or :gun_sup
in that supervisor as well.
BUt I'm not sure it is supported that way. Alternatively you could list
:gun
as an explicit dependency.
list
:gun
as an explicit dependency.
It works! Thank you.
I got this error:
I have
{:nostrum, "~> 0.9", runtime: false}
, withincluded_applications: [:nostrum]
.In
application.ex
, I conditionally start it.I think due to
runtime=false
,ConsumerGroup
is not started. But I don't know how to fix it. Any thoughts on this? Thank you.