cronokirby / alchemy

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

Error when trying to get a member from Cogs #30

Closed aguxez closed 7 years ago

aguxez commented 7 years ago

When I try to get a member information through the member macro in Cogs I get an error saying that It failed to find an entry for {member id}, it some times work and some times it doesnt, I'm pattern matching the results of Cogs.member and when I try to inspect it, it may work or it may not and I have not changed anything in the code while testing this ^^, this is the traceback:

11:42:14.296 [error] Task #PID<0.269.0> started from #PID<0.259.0> terminating
** (MatchError) no match of right hand side value: {:error, "Failed to find an entry for 126908590639415296 in section members"}
    (cass) lib/cass/cass_commands.ex:17: Cass.Commands.add/1
    (elixir) lib/task/supervised.ex:85: Task.Supervised.do_apply/2
    (stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3
Function: &Cass.Commands.add/1
....
# information about the member

This is the only thing I have on the code so, uh, nothing crazy...

Cogs.def add do
    {:ok, guild_id} = Cogs.guild_id
    {:ok, member} = Cogs.member
    IO.inspect member
end

A thought came in my mind about a rate limit but I don't think that's the error it would be displaying.

cronokirby commented 7 years ago

ATM the cache doesn't automatically load up offline members, so it's possible that an invisible user triggering this command wouldn't be present in the cache. It's also possible that connection issues cause the cache to not be fully loaded when the command gets triggered, thus leading to the same thing.

This could be "solved" by doing an API request, but I don't like the idea of hitting the api inside of these macros.

The fact that Cogs.member returns an error tuple does warn about the eventual possibility of failure, so I don't really consider this to be an issue.