cronokirby / alchemy

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

on_guild_join handler is not getting called (close to all of the time) #107

Closed wkpatrick closed 4 years ago

wkpatrick commented 4 years ago

Im having issues with adding a handler to on_guild_join. I added a debug statement to def handle("GUILD_CREATE", guild) do in lib/Discord/events.ex and that function is getting hit. I also added a debug statement to defmacro on_guild_join(func) do in lib/events.ex and it is not getting hit The code im using is as follows (plus the bot initialization, i have it also listening to messages and other events and those are working).

defmodule Debugging do
  use Alchemy.Events
  require Logger
  def manage_guild(guild) do
    Logger.debug("Bot Joined a Guild: #{guild.name}")
    Logger.debug(guild.name)
  end
  Alchemy.Events.on_guild_join(:manage_guild)
end

While trying some different things and debugging, I have seen the "Joined a guild " message twice in 50 tries, and im not too sure why that is. I am doing a bit of initial development and thus starting up the process and killing it with ctrl + c many times.

The event does not fire when both starting up the bot with guilds joined, and also when telling the bot when joining a new server. The events do not fire after killing the program and waiting a few minutes for the bots to show as offline in the guilds. The events do not fire after killing the program and starting it back up again.

I appreciate any information y'all can provide, im still relatively new to elixir so I might have missed something obvious.

Thanks

wkpatrick commented 4 years ago

As expected, this was an issue on my end. I was not handling on_guild_online, which was the event getting thrown in this case.