rmcafee / discord_ex

Discord Elixir Library
MIT License
48 stars 13 forks source link

Error when new members join #44

Open OccamsQuattro opened 6 years ago

OccamsQuattro commented 6 years ago

I'm getting the following error when new members join the chat:

15:25:32.872 [error] ** Websocket client DiscordEx.Client terminating in :websocket_handle/3
   for the reason :error::function_clause         
** Websocket message was {:binary,                                    
 <<131, 116, 0, 0, 0, 4, 100, 0, 1, 100, 116, 0, 0, 0, 7, 109, 0, 0, 0, 4, 100,
   101, 97, 102, 100, 0, 5, 102, 97, 108, 115, 101, 109, 0, 0, 0, 8, 103, 117,
   105, 108, 100, 95, 105, 100, 110, 8, 0, 3, ...>>}             
** Handler state was %{agent_seq_num: #PID<0.219.0>, client_id: ##REDACTED##,
  client_pid: #PID<0.218.0>,                                    
  guilds: [%{guild_id: ##REDACTED##, voice_states: []}],     
  handler: Xyz.Chat.Discord.Client, heartbeat_pid: #PID<0.238.0>,              
  rest_client: #PID<0.211.0>, session_id: "##REDACTED##",  
  token: "Bot ##REDACTED##"}
** Stacktrace: [{:websocket_client, :handle_response,
  [%{"code" => 0, "message" => "404: Not Found"}, DiscordEx.Client,
   {:websocket_req, :wss, 'gateway.discord.gg', 443, '/?v=6&encoding=etf',
    :infinity, :undefined, 1,
    {:sslsocket, {:gen_tcp, #Port<0.7518>, :tls_connection, :undefined},
     #PID<0.236.0>},
    {:transport, :ssl, :ssl, :ssl_closed, :ssl_error,
     [mode: :binary, active: true, verify: :verify_none, packet: 0]},
    "tJX/V0K79x1oJRhuDl6+Kg==", :undefined, 1, :undefined, :undefined,
    :undefined}],
  [file: '/home/projects/xyz/deps/websocket_client/src/websocket_client.erl',
   line: 512]},
 {:websocket_client, :handle_websocket_frame, 2,
  [file: '/home/projects/xyz/deps/websocket_client/src/websocket_client.erl',
   line: 467]}, {:gen_fsm, :handle_msg, 8, [file: 'gen_fsm.erl', line: 483]},
 {:proc_lib, :init_p_do_apply, 3, [file: 'proc_lib.erl', line: 247]}]

The bot has no problem receiving messages and sending messages. I cannot make sense of this error. Can someone help?

tielur commented 6 years ago

@OccamsQuattro Do you have a fallback handler in your bot?

# Default Fallback Handler for all events!
# This way things don't blow up when you get an event you
# have not set up a handler for.

def handle_event({event, _payload}, state) do
  IO.puts "Received Event: #{event}"
  {:ok, state}
end