cronokirby / alchemy

A discord library for Elixir
MIT License
152 stars 34 forks source link

[bug] Client.add_reaction/2 and Client.remove_reaction/2 crashes #109

Open aramsm opened 3 years ago

aramsm commented 3 years ago

Both functions are not working and giving the error above:

14:26:15.355 [error] Task #PID<0.295.0> started from #PID<0.304.0> terminating
** (ArgumentError) argument error
    :erlang.byte_size(%{"id" => nil, "name" => "✅"})
    (alchemy 0.6.6) lib/Discord/Endpoints/channels.ex:91: Alchemy.Discord.Channels.modify_reaction/6
    (alchemy 0.6.6) lib/Discord/rate_manager.ex:37: Alchemy.Discord.RateManager.process_req/3
    (elixir 1.10.2) lib/task/supervised.ex:90: Task.Supervised.invoke_mfa/2
    (stdlib 3.6) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
Function: &MyApp.add_a_reaction/4
    Args: [_arg1, _arg2, _arg3, %{"id" => nil, "name" => "✅"}]
aramsm commented 3 years ago

@cronokirby I found a bug where actually name is not a string but %{"id" => id, "name" => name} here and that makes the app crash here. That probably also happens in here, here and here, but I'm not sure. I have two options: track who is messing up the %Emoji{} and try to fix it, or make a parser via pattern match and redirect the right %Emoji{} to its function.