cronokirby / alchemy

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

BUG: Event stage crashes due to missing embed field #122

Closed Zarathustra2 closed 3 years ago

Zarathustra2 commented 3 years ago

There are new events that are missing the embed key. Haven't had the time to check which kind of events but I am on it. In the meantime, it is probably safer to always only do the mapping iff the key is present to prevent some crashes in the future if the discord API changes.

Here is a stack trace:

** (Protocol.UndefinedError) protocol Enumerable not implemented for nil of type Atom. This protocol is implemented for the following type(s): Ecto.Adapters.SQL.Stream, Postgrex.Stream, DBConnection.PrepareStream, DBConnection.Stream, KafkaEx.Stream, Timex.Interval, Floki.HTMLTree, HashDict, GenEvent.Stream, File.Stream, Map, IO.Stream, Function, HashSet, Stream, Range, MapSet, List, Date.Range
    (elixir 1.10.4) lib/enum.ex:1: Enumerable.impl_for!/1
    (elixir 1.10.4) lib/enum.ex:141: Enumerable.reduce/3
    (elixir 1.10.4) lib/enum.ex:3383: Enum.map/2
    (alchemy 0.6.8) lib/Structs/structs.ex:36: anonymous fn/2 in Alchemy.Structs.field_map/3
    (elixir 1.10.4) lib/map.ex:837: Map.get_and_update/3
    (alchemy 0.6.8) lib/Structs/structs.ex:36: Alchemy.Structs.field_map/3
    (alchemy 0.6.8) lib/Structs/Messages/message.ex:121: Alchemy.Message.from_map/1
    (alchemy 0.6.8) lib/Discord/events.ex:138: Alchemy.Discord.Events.handle/2
cronokirby commented 3 years ago

Yeah, this seems like a good idea